Re: controller question
Re: controller question
- Subject: Re: controller question
- From: Keary Suska <email@hidden>
- Date: Tue, 27 Sep 2011 08:40:05 -0600
On Sep 26, 2011, at 9:22 PM, Quincey Morris wrote:
> On Sep 26, 2011, at 19:03 , Ariel Feinerman wrote:
>
>> if I use persistence NSMutableArray as content array in NSArrayController so
>> [arrayController setContent: m_array]; will controller copy one or retain?
>
> The array controller will *observe* the array, not copy it.
I will take your word for how the controller is internally managing its content as I haven't inspected it, but although it is true that the controller should not copy the object (otherwise the docs should require that the content object conform to NSCopying), how the controller content is internally managed is not documented and shouldn't be relied on. Setting content is the same as setting any object property, and how the object is managed is no business of the setter.
>> So every deletion or addition in the controller will come back to origin.
>
> Yes.
Again, this isn't guaranteed since it relies to how the controller may be managing its content.
>> Or we must synchronize one or get from controller to write to url?
>
> No, you don't have to either of those things.
>
> However, if you modify the array directly, you have to do it KVO compliantly, or the array controller won't see the change.
Again, same issue. When not using bindings, you shouldn't rely on the behavior, even if it happens to work (for now)...
In sum, if you want synchronization without glue code, use bindings. If you don't need to manage the array outside of the controller you can retrieve the array contents when you need it as well...
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden