Re: synchronize the content of two arrays with binding
Re: synchronize the content of two arrays with binding
- Subject: Re: synchronize the content of two arrays with binding
- From: "Mei Fang Liau" <email@hidden>
- Date: Sun, 24 Feb 2008 02:54:02 +0100
Hello Bill,
thanks a lot for the suggestion! however, could you please give me a simple
example?
this is how I envision the program works:
In my custom view (RingView) there are 16 toggle buttons, once any button in
the ringview is triggered, it will inform AppController about the change.
AppController has an extra array in order to keep in sync with the RingView.
Which is also the same size of the toggle array from RingView...
I checked some examples and tutorials about bindings, which seem to normally
bind two different data sources key by key... but what I want to do is just
to sync the "toggle array" from RingView with another array in AppController
(so that AppController can pass the changes to other controllers/ views).
Can I reach this in a less painful way? Thanks again for the help!
2008/2/21, Bill Garrison <email@hidden>:
>
>
> On Feb 20, 2008, at 5:23 AM, Mei Fang Liau wrote:
>
> > I have a boolean array from a custom view and would like to
> > synchronize the
> > content of the array with another boolean array from a custom
> > controller
> > (inherited from NSObject) These two arrays has the same capacity( bool
> > test1[16] and bool test2[16] respectively)
> >
> > I tried [testView bind:@"test1" toObject: testController withKeyPath:
> > @"test2" options:nil];
>
>
> I would try using key-value observing (KVO) instead of bindings for
> this problem. You have two arrays and you want to keep one of them in
> sync with the other.
>
> That said, the arrays have to be NSArray, not C-based arrays. It's
> not clear from your description above if the actual arrays are
> NSArrays. Bindings and key-value observer only work with Cocoa data
> structures, not C/C++ structures.
>
> If the arrays are really C-based structures, you'll probably need to
> manage the synchronization in a brute-force manual way.
>
>
> Bill
>
_______________________________________________
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