开发者

Setting text for NSTextView with an NSString variable, considering reference counting

开发者 https://www.devze.com 2022-12-20 02:52 出处:网络
I have the following code in a function in my .m file: desc = [my executeFunction]; // desc is returned by executeFunction

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?


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/.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消