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 03-29-2009, 03:53 PM   #35 (permalink)
smasher
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Quote:
Originally Posted by .mb View Post
Ahh, that makes sense. One more question, if I could. I'm trying to destroy objects dynamically, but I'm drawing a blank on how to remove it from memory... Trying to use [object dealloc] just freezes the application, and removing it from the array does the same.
Objects get destroyed when their "retain count" hits zero. Usually, that means you intit the object (for a count of one) and it gets destroyed when you release it. You never call dealloc yourself.

The confusion comes in when you *don't* init the objects - many classes have "convenience methods" that give you "autorelease" objects, that will release themselves at the end of the current event. If you release an object you did not init, you usually get a crash.

Properties and arrays/dictionaries also retain objects when you add them, and release them once when you remove them.

This is the page that put it all together for me:
Very simple rules for memory management in Cocoa

PS- views also retain their subviews. So you'll have to call [deadView removeFromSuperview] too, if it's a view.
__________________

Free Games!
smasher is offline   Reply With Quote
 

» Advertisements
» Online Users: 329
17 members and 312 guests
ADY, apatsufas, chemistry, Fit4him, headkaze, ilmman, MarkC, marto1914, Meoz, Promo Dispenser, PsychoChris, sly24, sneaky, Sunny46, tgjorgoski, Thrillhouse1919, vogueestylee
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,877
Threads: 89,222
Posts: 380,718
Top Poster: BrianSlick (7,129)
Welcome to our newest member, peterkessler45
Powered by vBadvanced CMPS v3.1.0

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