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 01-23-2009, 04:18 PM   #4 (permalink)
MattjDrake
iOS Developer Trainer
 
Join Date: Dec 2008
Location: Northeast United States
Posts: 141
Send a message via AIM to MattjDrake Send a message via Skype™ to MattjDrake
Default

This is probably one of the hardest things to get used to on the iPhone.

It helps to keep in mind that you must release something after you have used "alloc" when your create an object. This is usually used with "init" to create instances of an object. What gets confusing is that some classes have functions that do the same thing.

For example, check out the difference between these two ways to create a string:

NSString *string1 = [[NSString alloc] initWithString:@"needs to be released"];

NSString *string2 = [NSString stringWithString:@"no need to release"];

Both these things do the same thing but you do not need to worry about releasing the second one because you can assume that it is "autoreleased". It is a sort of unspoken rule that situations like string2 above are autoreleased while string1 will need to be explicitly released.

At any rate, this is clearly a complex issue. What I used to help me deal with this problem was that I bought a video (think it was about 10 bucks) from the Mac Developer Network that tells you everything you need to know about memory management.

Mac Developer Network » Blog Archive » Memory Management in Objective-C

They do a much better job of dealing with this problem then the Apple documentation does and they have some tips on how to cope with memory management. Highly recommend it.
__________________
How To Make iPhone Apps
http://howtomakeiphoneapps.com
Cocoa-Touch, iPad & iPhone Programming Videos, Tutorials & How-To exclusively for new app developers
MattjDrake is offline   Reply With Quote
 

» Advertisements
» Online Users: 637
14 members and 623 guests
apatsufas, ckgni, Dani77, Domele, drewrico, handmachine, Harisstimolth5, JamesCahall, Janyeok, mistergreen2011, Monstertaco, noobAppDeveloper, Oral B, rimap123
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,789
Threads: 89,205
Posts: 380,603
Top Poster: BrianSlick (7,129)
Welcome to our newest member, Harisstimolth5
Powered by vBadvanced CMPS v3.1.0

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