On 03/01/2011, at 10:17 AM, Brian Durocher wrote:

> This line of code seems to work for exactly what I was looking for:
> 
>    temp = [[temp stringByAppendingFormat:@" %@ %@ \n", input1, input2]
> retain];


Except it's quite wrong from a memory management point of view.

As well as the excellent advice you've already received, you really must take 
my advice about not just reading but KNOWING the memory management rules:

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html

C++, with which you're familiar, has no built-in memory management except 
allocation and free. You have to track those allocations yourself if you are to 
prevent leaks and so on. In Cocoa, this tracking is about 80% handled for you 
provided you follow the rules. The rules are there to ensure that the tracking 
works. (Or you can enable garbage collection and then the tracking is 100% 
handled for you).

> although I have to admit I am unsure really what the "retain" will
> actually do here with respect to memory.

Which means you haven't read the rules, let alone committed them to heart. I 
urge you to do so before progressing further.

--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to