views:

122

answers:

2

I have the following code in a function in my .m file:

desc = [my executeFunction]; // desc is returned by executeFunction
data = [desc objectAtIndex:0]; // data is declared in the .h file
data2 = [desc objectAtIndex:1];
[myTextField setString:data]; // myTextField is connected to an NSTextView in IB
[myTextField setString:data2];

How am I supposed to be writing the 4th and 5th lines? How / where do I release data and data2?

+1  A: 

You don't. You haven't received data or data2 from a method with a selector containing alloc, new or copy or a function with a name containing Create, so you are not responsible for releasing them.

Have a look at http://boredzo.org/cocoa-and-cocoa-touch-intro/.

Rob Keniger
+1  A: 

Revise the Cocoa Memory Management Guidelines and determine whether releasing is necessary in this case. There are very specific, yet very simple rules regarding a retain and release pattern. Commit these rules to memory (pun intended).

dreamlax