Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 05-09-2011, 04:17 PM   #1 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 8
jayboy is on a distinguished road
Default Error "Wrong type argument to unary minus"

Hi guys, I've been getting getting the error "Wrong type argument to unary minus" and I can't seem to make it disappear.

Please help!

Code:
- (IBAction)toggleTracking

{
	if (tracking)
        
	{
		tracking = NO;
		
		[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
		startButton.title = @"Start Tracking";
		[locationManager stopUpdatingLocation];
		[locationManager stopUpdatingHeading];
		mapView.scrollEnabled = YES;
		mapView.zoomEnabled = YES;
    
		
		
		
		//--NSTimeInterval *
        
        //--double *time = (double)[startDate timeIntervalSinceNow];
		
		//float timeF = 5678; //(float)*time;
		
		//NSString *message = [NSString stringWithFormat:@"Distance: %.02f km, %.02f mi\nSpeed: %.02f km/h, %.02f mph", distance / 1000.0, distance * 0.00062, distance * 3.6 / timeF, distance * 2.2369 / timeF];
    
        float time = -[startDate timeIntervalSinceNow];
        
        NSString *message = [NSString stringWithFormat:
                             @"Distane: %.02f km, %.02f mi\nSpeed: %.02f km/h, %.02f mph",
                             distance / 1000, distance * 0.00062, distance * 3.6 /time,
                             distance * 2.2369 / time];
        
		UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Statistics" message:message delegate:self cancelButtonTitle:@"Return" otherButtonTitles:nil];
		[alert show];
		[alert release];
	}
Been getting the error on the line where it says -- float time = -[startDate timeIntervalSinceNow];

Thanks in advance
jayboy is offline   Reply With Quote
Old 05-09-2011, 08:42 PM   #2 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

I fail to see how this is an advanced topic. Just so you know, I think less people look at the advanced discussion page than the regular page. Anyways just remove the *, so it'll be
Code:
double time =
Domele is offline   Reply With Quote
Old 05-10-2011, 05:47 AM   #3 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 8
jayboy is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
I fail to see how this is an advanced topic. Just so you know, I think less people look at the advanced discussion page than the regular page. Anyways just remove the *, so it'll be
Code:
double time =
Sorry, im new to this forum.
I've tried removing it but im still getting the same error.
I'm getting the error on the line where it says:
Code:
float time = -[startDate timeIntervalSinceNow];
jayboy is offline   Reply With Quote
Old 05-10-2011, 05:56 AM   #4 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

NSTimeInterval time = [startDate timeIntervalSinceNow];
__________________
dany_dev is offline   Reply With Quote
Old 05-10-2011, 07:29 AM   #5 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 8
jayboy is on a distinguished road
Default

Im still getting an error :S HELP!!!
jayboy is offline   Reply With Quote
Old 05-10-2011, 05:20 PM   #6 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

What is the error? Dany_dev's solution should of worked.
Domele is offline   Reply With Quote
Old 05-10-2011, 05:21 PM   #7 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default

Quote:
Originally Posted by jayboy View Post
Sorry, im new to this forum.
I've tried removing it but im still getting the same error.
I'm getting the error on the line where it says:
Code:
float time = -[startDate timeIntervalSinceNow];
Do you mean:

Code:
float time -= [startDate timeIntervalSinceNow];
iSDK is offline   Reply With Quote
Old 05-10-2011, 05:43 PM   #8 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 8
jayboy is on a distinguished road
Default

Quote:
Originally Posted by iSDK View Post
Do you mean:

Code:
float time -= [startDate timeIntervalSinceNow];
I've tried doing that but it doest work :S
jayboy is offline   Reply With Quote
Old 05-10-2011, 05:48 PM   #9 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 8
jayboy is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
What is the error? Dany_dev's solution should of worked.
Tried that too i'm afraid. No luck! :S

I've uploaded my application in case any one wants to take a look at it.
Here is the link:
TrackUrRouteFinal.zip
jayboy is offline   Reply With Quote
Old 05-10-2011, 05:50 PM   #10 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default

Quote:
Originally Posted by jayboy View Post
Tried that too i'm afraid. No luck! :S

I've uploaded my application in case any one wants to take a look at it.
Here is the link:
TrackUrRouteFinal.zip
NSData doesn't have the variable: timeIntervalSinceNow. Thats why you are receiving the error.
iSDK is offline   Reply With Quote
Old 05-10-2011, 05:52 PM   #11 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 8
jayboy is on a distinguished road
Default

Quote:
Originally Posted by iSDK View Post
NSData doesn't have the variable: timeIntervalSinceNow. Thats why you are receiving the error.
So whats the solution? NSDate is it?
jayboy is offline   Reply With Quote
Old 05-10-2011, 05:54 PM   #12 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default

Quote:
Originally Posted by jayboy View Post
So whats the solution? NSDate is it?
That would be correct.
iSDK is offline   Reply With Quote
Old 05-10-2011, 06:08 PM   #13 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 8
jayboy is on a distinguished road
Default

I think I've solved it. Thanks everyone for their effort.
One last thing. To test Core Location does the app need to be on the phone?
Doubt i can test it with simulator since my mac book doesn't have GPS?
jayboy is offline   Reply With Quote
Old 05-10-2011, 06:46 PM   #14 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

You can do basic tests of Core Location in the Simulator, but you will always be standing still, so you need a device to get any real testing done.
__________________
My development blog: http://jrinn.com
JasonR is offline   Reply With Quote
Old 05-11-2011, 09:22 AM   #15 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 8
jayboy is on a distinguished road
Default

Quote:
Originally Posted by JasonR View Post
You can do basic tests of Core Location in the Simulator, but you will always be standing still, so you need a device to get any real testing done.
Thanks dude
jayboy is offline   Reply With Quote
Reply

Bookmarks

Tags
xcode error

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 404
20 members and 384 guests
Absentia, AyClass, baja_yu, checkright, Diligent, dre, epaga, fvisticot, givensur, jbro, jPuzzle, momolgtm, Newbie123, Punkjumper, revg, sacha1996, skrew88, taylor202, tomtom100
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,643
Threads: 94,110
Posts: 402,858
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Diligent
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:38 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0