我们知道 Apple Transitioning to ARC Release Notes
Which classes don’t support weak references?
You cannot currently create weak references to instances of the following classes:
NSATSTypesetter, NSColorSpace, NSFont, NSMenuView, NSParagraphStyle, NSSimpleHorizontalTypesetter, and NSTextView.
Note: In addition, in OS X v10.7, you cannot create weak references to instances of NSFontManager, NSFontPanel, NSImage, NSTableCellView, NSViewController, NSWindow, and NSWindowController. In addition, in OS X v10.7 no classes in the AV Foundation framework support weak references.
所以问题是 如何在 block 中使用 NSTextView?
,如果不使用 weak , block 将持有强 NSTextView ref。
我担心应用程序无法释放 NSTextView。
我该怎么办?
在下面试试:
NSTextView * __block textView = [[NSTextView alloc] init…];
为此添加 __block 以在 block 中解决并出于发布目的,您需要在完成 block 中或根据您的使用情况显式释放它。
关于ios - 如何在 block 中使用 NSTextView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34508035/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |