6

I noticed than in OSX, the NSTextView cannot for a weak refference (if you try to link it weak, you will get)

Cannot form weak reference to instance (0x600000122da0) of class NSTextView. It is possible that this object was over-released, or is in the process of deallocation.

also the outlet from XCode is created as assign by default

Why there cannot be a weak reference? What can be the reason?

Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
  • 3
    [this question](http://stackoverflow.com/questions/12882710/iboutlet-for-nstextview-in-a-arc-project) may be what you are looking for. – meth Feb 12 '16 at 11:45

2 Answers2

4

Check FAQ here Transitioning to ARC Release Notes:

Q:Which classes don’t support weak references?

A:You cannot currently create weak references to instances of the following classes: NSATSTypesetter, NSColorSpace, NSFont, NSMenuView, NSParagraphStyle, NSSimpleHorizontalTypesetter, and NSTextView.

etc.

avojak
  • 2,342
  • 2
  • 26
  • 32
alexkod
  • 41
  • 3
-2

Read the message carefully. Read past the word NSTextView. It tells you exactly why at this moment you cannot create a weak reference to the NSTextView. You just have to read it.

For example, while dealloc is running, you cannot create new weak references anymore because the object will be going away and all weak references will be set to nil. Trying to assign the object to a weak variable will keep that variable nil, even though the object is not nil (yet).

And this has nothing to do with NSTextView.

gnasher729
  • 51,477
  • 5
  • 75
  • 98
  • 2
    thats not correct, the problem is that NSTextView uses it's own reference counting and therefore cannot be used with weak reference – Peter Lapisu Feb 12 '16 at 15:09