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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 04-29-2009, 01:58 PM   #14 (permalink)
remover
Registered Member
 
Join Date: Apr 2009
Posts: 27
Default

Quote:
Originally Posted by ckcheng View Post
I have this problem before in my code, and let me guess, you have created the array in your "init" or "initWith...." method, right?

To properly create a property with code (that is, not a UI control from Interface Builder) in "init" method, *always* retain your property.

In short,

myNSMutableArray = [[NSMutableArray alloc] initWith....];

should be

myNSMutableArray = [[[NSMutableArray alloc] initWith....] retain];

this way, even your "init" method ends, the retain count of "myNSMutableArray" will prevent the system to free/release your object.

Alternatively, since you declare the property in (retain) way, you can use

self.myNSMutableArray = [[NSMutableArray alloc] initWith...];

Using accessor will do the retain for you.


thank you for this post. I would've been there all day. retain, retain, retain!
remover is offline   Reply With Quote
 

» Advertisements
» Online Users: 347
16 members and 331 guests
ADY, BdR, dacapo, fiftysixty, F_Bryant, iDifferent, john love, kampftrinker, ligerligerliger, mer10, mizzytheboy, nobre84, syver, themathminister, XRumerTest
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,876
Threads: 89,225
Posts: 380,701
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jorge599
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:29 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.