Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 09-05-2008, 05: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
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Online Users: 461
30 members and 431 guests
alexy, asimrs, Boh, bugman, dany88, Dmitry, DoBs, Erle, fnicola, gluse, greetings, hatembr, hg4072, ivanraso, joalta, Johanovski, manofham, Meoz, myPhone, nikhil, ovidiu, Salman, sandman4sure, sanjeev, skunk, SteveMobs, thomaswguy, tychop, umop, vikysaran
Most users ever online was 779, 05-11-2009 at 09:55 AM.
» Stats
Members: 24,095
Threads: 38,876
Posts: 170,546
Top Poster: smasher (2,563)
Welcome to our newest member, hg4072
Powered by vBadvanced CMPS v3.1.0

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