I think the cause is “&(myArray[0])”. In Swift it isn't possible to get a 
pointer to an array item — these aren’t C arrays, their internal representation 
is opaque! So what I think happens is that it copies myArray[0] into a 
temporary and creates an UnsafeMutablePointer to that. Then, after the call, it 
assumes that the call might have mutated that temporary, so it stores it back 
into myArray.

Then, mutating myArray is logically equivalent to copying it, modifying the 
copy, and storing the copy back into the property. (Apparently it’s often 
optimized, fortunately, but those are the semantics.) Which means that your 
‘didSet’ handler gets called.

—Jens
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to