我们知道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 将持有 strong NSTextView 引用。
我担心应用无法释放 NSTextView。
我该怎么办?
最佳答案
试试下面:
NSTextView * __block textView = [[NSTextView alloc] init…];
为此添加 __block 以在 block 中解决问题,为了发布目的,您需要在完成 block 中或根据您的使用情况明确发布它。
关于ios - 如何在 block 中使用 NSTextView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34508035/