71
74

More than 5 years have passed since last update.

weak 参照してはいけない Cocoa のクラス一覧

Last updated at Posted at 2013-05-24

Transitioning to ARC Release Notes によれば、 OS X 10.8 において以下のクラスが weak 参照に対応していない:

  • NSATSTypesetter
  • NSColorSpace
  • NSFont
  • NSMenuView
  • NSParagraphStyle
  • NSSimpleHorizontalTypesetter
  • NSTextView

OS X 10.7 では、上記に加えてこれらのクラスも weak 参照してはならない:

  • NSFontManager
  • NSFontPanel
  • NSImage
  • NSTableCellView
  • NSViewController
  • NSWindow
  • NSWindowController
  • AV Foundation のすべてのクラス

weak 参照した場合 "cannot form weak reference to instance (<address>) of class <ClassName>" とランタイムエラーが発生する。

これらのクラスを弱参照したい場合は、変数を __unsafe_unretained で修飾するか、プロパティ属性を unsafe_unretained (または assign)にすること。参照はゼロ化されないことに注意。

71
74
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
71
74