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

Reply
 
LinkBack Thread Tools Display Modes
Old 08-01-2010, 09:12 PM   #1 (permalink)
Registered Member
 
Ovidius's Avatar
 
Join Date: Jun 2010
Posts: 77
Ovidius is on a distinguished road
Exclamation Float Values

I have a float value in a custom class (named DrawingLayer) declared as:

Code:
float totalTimeDifference;
@property(readwrite, assign) float totalTimeDifference;
I also synthesize it with:

Code:
@synthesize totalTimeDifference;
The class named DrawingLayer is an MKMapViewDelegate. I do some operations on this float value in the didUpdateUserLocation method:

Code:
NSTimeInterval difference = [userLocation.location.timestamp timeIntervalSinceDate:lastUserLocation.timestamp];
self.totalTimeDifference = self.totalTimeDifference + (float)difference;
It works well, I can output the float to a label in the application, so I know it gets incremented (and works).

However, in a separate method of the DrawingLayer class, I try to output this float value to the NSLog:

Code:
NSLog(@"The total time difference is: %f.", self.totalTimeDifference);
When I try to output it, the float value is always 0.000000! Am I not setting its property correctly? I'm not sure what the problem is. Can someone please help me out and tell me what is going on here? I haven't got the slightest clue! I don't get why it works in one method, but not this one. Does it get retained locally or something!? I need to pass this value to a method in another class, so I really need to be able to get its float value!
Ovidius is offline   Reply With Quote
Old 08-01-2010, 09:28 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

Are you sure that both references are to the same instance of DrawingLayer?
RLScott is offline   Reply With Quote
Old 08-01-2010, 09:36 PM   #3 (permalink)
Registered Member
 
Ovidius's Avatar
 
Join Date: Jun 2010
Posts: 77
Ovidius is on a distinguished road
Default

Quote:
Originally Posted by RLScott View Post
Are you sure that both references are to the same instance of DrawingLayer?
Yep. I mean, DrawingLayer is only initialized and allocated once, so it has to be referring to the same exact object! - if that's what you mean.
Ovidius is offline   Reply With Quote
Old 08-01-2010, 09:52 PM   #4 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

Is it possible that some code is resetting the value to zero?.
RLScott is offline   Reply With Quote
Old 08-01-2010, 09:58 PM   #5 (permalink)
Registered Member
 
Ovidius's Avatar
 
Join Date: Jun 2010
Posts: 77
Ovidius is on a distinguished road
Default

Quote:
Originally Posted by RLScott View Post
Is it possible that some code is resetting the value to zero?.
Oh, man...that's exactly what was happening...@#$% I spent like three hours trying to figure it out, thinking it was something complicated...thanks so much! I'm sorry I started this thread...I feel like a complete nooblet.
Ovidius is offline   Reply With Quote
Reply

Bookmarks

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: 326
9 members and 317 guests
alexP, gordo26, headkaze, mistergreen2011, nobstudio, Objective Zero, rayjeong, revg, Sloshmonster
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

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