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 09-05-2008, 06:14 AM   #5 (permalink)
ckcheng
New Member
 
Join Date: Sep 2008
Posts: 8
Default

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.
ckcheng is offline   Reply With Quote
 

» Advertisements
» Online Users: 801
18 members and 783 guests
ADY, AppAnnex, at0m87, bocaraton, charles.scholten, Domele, drviii, gabacus, Hirley2324, Jaxen66, KarlJay, smarkmee, srilu, suresk, thitikorn, thutrangiphonedevsdk, ugur, Vineesh
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,630
Threads: 89,148
Posts: 380,343
Top Poster: BrianSlick (7,110)
Welcome to our newest member, thitikorn
Powered by vBadvanced CMPS v3.1.0

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