Re: Binding NSButton state to an NSMutableArray inside anNSMutableArray
Re: Binding NSButton state to an NSMutableArray inside anNSMutableArray
- Subject: Re: Binding NSButton state to an NSMutableArray inside anNSMutableArray
- From: email@hidden
- Date: Fri, 15 Aug 2008 22:58:19 +0200
1.Sh*t: *Never* respond with a webmailer. I will copy my answers to the last mails tomorrow, when I'm at work. However Markus can do this, too.
>I too have something similar I'm trying to tackle ...
>
>I'd like binding to show/hide a label item based on a value in an
>array. I've thought about using a transformer but was not able to make
>that work.
>
>Any suggstions would be great.
2. The hide property of a view is a "single item". you can bind a "single property" to an array by
2.1. using a aggregate (@min et al.) to make it a "single property"
2.2. using a selection,that refers to one item inside the array.
If you have an array of an array you need a "double aggregate" (I think, that this is not possible) or by two selections of two array controllers (the selection inside the backend array as a(to-many) property of the selection inside the frontend array)
If you describe your model more closely, somebody would help you.
Cheers,
Amin
>
>jack
>
>On Aug 15, 2008, at Fri-08 /15 /08-2:10 PM, TouchCab Developer wrote:
>
>> Hi list.
>>
>> I'm new to the list and fairly new to cocoa, although many years of
>> programming assembler, C and C++ helps a lot. I'm getting the hang
>> of Objective-C and enjoying it very much.
>>
>> In my App Delegate file I keep an NSMutableArray of "base" objects
>> which is my application's data core.
>> I need an arbitrary number of Windows/Panels to access this array,
>> and show/manipulate the contents of one of the base objects,
>> selectable by a designated key in my object using an NSTableView in
>> the window. This works nicely for most objects inside the base
>> objects, binding an NSArrayController to the array.
>>
>> Each base object, however, holds an NSMutableArray of NSNumbers. I
>> want the boolean value of these NSNumbers to represent the state of
>> an equal number of buttons in the window, so that if one of the
>> NSNumbers changes its value, the state of the corresponding NSButton
>> changes as well.
>>
>> The message flow is:
>> 1) Click button -> IBAction: send message to network device and
>> reset button to its former state (to show nothing happened yet).
>> 2) Receive reply from network device -> update the NSNumber, thereby
>> updating the state of the button to show the user that something
>> happened out there
>>
>> The reason for doing it this way is I want to show the user that the
>> change actually took place in the network device, and not just the
>> button changing state, assuming everything went well. I use an on/
>> off button, since momentary buttons don't show their state.
>> The reply from the network device holds information about the index
>> in the array, and I can get as far as setting the NSNumbers in the
>> nested array using replaceObjectAtIndex from the input stream
>> handler, but I can't bind that array to the button states.
>>
>> I have tried a second NSArrayController (well, I've tried a lot of
>> things), and I can bind to the nested array, but I can't for the
>> life of me figure out how I bind the NSNumbers in the nested array
>> to my button states. Perhaps I need to place the buttons in an array
>> and bind the contents of the array in the base object to the
>> contents of the array in the NSWindowController?
>> For now, I have scrapped the nested array altogether and have a
>> bunch of internal variables with getters and setters in both ends.
>> In the input stream handler, I build a selector to the setter
>> functions from the index information. It works, but it seems very un-
>> cocoa-ish, and it's certainly not pretty.
>>
>> Does anyone know how to do this?
>>
>> Regards, and thanks in advance,
>> Jens
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> 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
>
>_______________________________________________
>
>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
_______________________________________________
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