05-09-2011, 04:17 PM
#1 (permalink )
Registered Member
Join Date: May 2011
Posts: 8
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
05-09-2011, 08:42 PM
#2 (permalink )
Just helping out.
Join Date: Feb 2011
Posts: 2,565
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
05-10-2011, 05:47 AM
#3 (permalink )
Registered Member
Join Date: May 2011
Posts: 8
Quote:
Originally Posted by
Domele
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
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];
05-10-2011, 05:56 AM
#4 (permalink )
Nuisance Developer
Join Date: Jul 2009
Location: Italy
Posts: 4,691
NSTimeInterval time = [startDate timeIntervalSinceNow];
__________________
05-10-2011, 07:29 AM
#5 (permalink )
Registered Member
Join Date: May 2011
Posts: 8
Im still getting an error :S HELP!!!
05-10-2011, 05:20 PM
#6 (permalink )
Just helping out.
Join Date: Feb 2011
Posts: 2,565
What is the error? Dany_dev's solution should of worked.
05-10-2011, 05:21 PM
#7 (permalink )
Indie Developer
Join Date: Jul 2010
Posts: 1,346
Quote:
Originally Posted by
jayboy
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];
05-10-2011, 05:43 PM
#8 (permalink )
Registered Member
Join Date: May 2011
Posts: 8
Quote:
Originally Posted by
iSDK
Do you mean:
Code:
float time -= [startDate timeIntervalSinceNow];
I've tried doing that but it doest work :S
05-10-2011, 05:48 PM
#9 (permalink )
Registered Member
Join Date: May 2011
Posts: 8
Quote:
Originally Posted by
Domele
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
05-10-2011, 05:50 PM
#10 (permalink )
Indie Developer
Join Date: Jul 2010
Posts: 1,346
Quote:
Originally Posted by
jayboy
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.
05-10-2011, 05:52 PM
#11 (permalink )
Registered Member
Join Date: May 2011
Posts: 8
Quote:
Originally Posted by
iSDK
NSData doesn't have the variable: timeIntervalSinceNow. Thats why you are receiving the error.
So whats the solution? NSDate is it?
05-10-2011, 05:54 PM
#12 (permalink )
Indie Developer
Join Date: Jul 2010
Posts: 1,346
Quote:
Originally Posted by
jayboy
So whats the solution? NSDate is it?
That would be correct.
05-10-2011, 06:08 PM
#13 (permalink )
Registered Member
Join Date: May 2011
Posts: 8
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?
05-10-2011, 06:46 PM
#14 (permalink )
Super Moderator
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
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.
05-11-2011, 09:22 AM
#15 (permalink )
Registered Member
Join Date: May 2011
Posts: 8
Quote:
Originally Posted by
JasonR
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
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» 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