Re: Binding NSButton state to an NSMutableArray inside an NSMutableArray
Re: Binding NSButton state to an NSMutableArray inside an NSMutableArray
- Subject: Re: Binding NSButton state to an NSMutableArray inside an NSMutableArray
- From: Negm-Awad Amin <email@hidden>
- Date: Mon, 18 Aug 2008 09:18:25 +0200
Hi
you did a part of the work. Using a second array controller is
correct, because you have a second array.
What you need is a UI, that depends on the number and content of the
items contained in the second array. There are two views, that provide
this: NSTableView and – I think this is the correct one for your UI –
NSMatrix.
So try using an instance of NSMatrix.
Cheers
Amin
Am Fr,15.08.2008 um 20:10 schrieb TouchCab Developer:
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
Amin Negm-Awad
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