开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜