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 07-07-2010, 09:04 PM   #1 (permalink)
Registered Member
 
wheli's Avatar
 
Join Date: Jan 2010
Posts: 130
wheli is on a distinguished road
Default NSString retaining broken after upgrading to iOS4

Hey Guys,

I "was" completely done with an app and decided to upgrade my iPhone SDK to 4.0 to do some testing. Unfortunately, I have discovered that my app is not working with the 4.0 firmware.

I have a class that has an NSString attribute that is not retaining its value correctly. I am declaring it like this within the header file:


Code:
@interface SensorReading : NSObject {
	UINavigationController *navigationController;
	NSString *sensor;

}
@property(nonatomic,retain) NSString *sensor;
at the top of the .m file i have:

Code:
@synthesize sensor;
but for some reason "sensor" is not holding its value. It will save the value until it leaves the helper function where it is assigned, but not after that...and it DOES work in 3.x firmware. I am assigning the string like this:

Code:
sensor = string;
You guys have any idea why this might be happening? My app just crashes the next time I try to access "sensor".

Thanks for any help you can provide!

Last edited by wheli; 07-07-2010 at 09:06 PM.
wheli is offline   Reply With Quote
Old 07-07-2010, 09:07 PM   #2 (permalink)
iPhone SDK learner
 
Join Date: Feb 2010
Location: Illinois, USA
Posts: 421
Batman is on a distinguished road
Default

Code:
sensorUnits = string;
Isn't it called sensor??? Anyway if string is autoreleased so will sensor. Either make it so string is retained or use self.sensor = string;
Batman is offline   Reply With Quote
Old 07-07-2010, 09:12 PM   #3 (permalink)
Registered Member
 
wheli's Avatar
 
Join Date: Jan 2010
Posts: 130
wheli is on a distinguished road
Default

sorry...i noticed that after i posted and then fixed it....

the putting "self." in front of the variables fixed the problem!
i guess i should have checked here an hour or two ago.

dunno why that would only be exposed in iOS4, but thanks for the help!
wheli is offline   Reply With Quote
Old 07-07-2010, 09:39 PM   #4 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

Quote:
Originally Posted by wheli View Post
dunno why that would only be exposed in iOS4,...
It was just good luck that it did not fail before. When you access memory that has been released, it may or may not have been used for some other purpose.
RLScott 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: 351
14 members and 337 guests
akacaj, c2matrix, cgokey, esoteric, EXOPTENDAELAX, GHuebner, givensur, HemiMG, Mirotion22, mjnafjke, Pudding, SLIC, Sonuye857, Techgirl-52
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,652
Threads: 94,115
Posts: 402,887
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Sonuye857
Powered by vBadvanced CMPS v3.1.0

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