Domanda

I'd like to be sure about something.

Suppose I have a NSArray, with some objects. Suppose that those objects are observed.

Now, if I create another NSArray with the first one (initWithArray:copyItems:NO), will the observation be untouched ?

And if I create with copying (initWithArray:copyItems:YES), will the observation follow the new objects in the new array ?

Thanks !

È stato utile?

Soluzione

The observation is linked to the original objects by their pointers.

If you create a new array without copying then the objects are the same. The observation doesn't change, you just have multiple references to the same objects.

If you create a new array with copying then the objects are different but the original objects still exist in the original array. The observation doesn't change, you are still observing the original objects. The new objects are effectively unrelated and have no observers.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top