Re: Newbie Trouble with Basic Bindings
Re: Newbie Trouble with Basic Bindings
- Subject: Re: Newbie Trouble with Basic Bindings
- From: mmalcolm crawford <email@hidden>
- Date: Tue, 15 Mar 2005 18:55:32 -0800
On Mar 15, 2005, at 3:59 PM, Kane Dijkman wrote:
I have put a .sit of the project at <a href="http://
www.digitalemerald.com/livejournal/StockManager.sit"> http://
www.digitalemerald.com/livejournal/StockManager.sit</a> for anyone
that might be willing to look at the code or wants a good laugh. If
you do download and run it you will need to enter a preferences
path to a folder of files that should be listed.
I've tried downloading that but StuffIt claims the file is corrupted.
If you recreate it, (a) Please just use the archiver in Finder; (b)
Please clean the project first.
That apart, given:
listPath = [NSArray arrayWithObject:@"No lists found"];
}
listFilesArray = [NSMutableArray arrayWithArray:listPath];
I would guess that your array is composed just of strings? Bindings
don't work well with "simple" objects -- they require the data
objects to be KVC compliant. As a minimum you should be using
dictionaries.
Note, by the way, that listFilesArray is autoreleased. If this is
working, then your array is probably being retained by the array
controller -- in other situations you will not be so lucky, and your
application will crash when something tries to access the freed
object. You should get into the habit of using accessor methods (see
for example <http://www.stepwise.com/Articles/Technical/
2001-03-11.01.html>).
1. Am I even remotely doing the binding right?
Modulo the point above (about using dictionaries), probably.
What I want is an Array of items (in this case files name) to be
displayed in the NSTableView. It is working right now, but I dont
think I have it setup right since it required the listFilesArray in
the ControllerBinding too.
I'm not sure what this means, and in particular how it relates to:
"This is bound to "ControllerBindings" which is an NSObjectController
that has an outlet connection to the Controller and also has
"listFilesArray" as an attribute used in the bindings."
2. Provided that question 1 is "yes, this is right" why do
programatic changes to the items in the array not show up in the
Table View? If I just run [listFilesArray addObject:@"penguin"]; it
does not show up.
This is explained at <http://homepage.mac.com/mmalc/CocoaExamples/
controllers.html>, section "Programmatic modifications to arrays not
noticed by table view".
3. How can I find out what values are selected by the user? I want
to be able to show a list of files, have the user click the Run
button (which calls the run method) and I will want to do something
based on their selection. I do not know how to figure out what has
been selected through the Bindings.
See:
<http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/ObjC_classic/Classes/NSArrayController.html#//
apple_ref/doc/uid/20002042/BAJECHFD> ('selectedObjects').
4. In general, are there any good books on Bindings? I have scoured
the web and read and reread every tutorial and example on binding
over the last few days and am still not sure how to do much with
them. They sound great, and I really want to learn and understand
them but so far besides some messy code all I have to show for it
is a heck of a headache.
Cocoa Bindings
<http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/>
<http://developer.apple.com/documentation/Cocoa/Reference/
CocoaBindingsRef/>
<http://developer.apple.com/cocoa/cocoabindings.html>
<http://homepage.mac.com/mmalc/CocoaExamples/controllers.html>
<http://www.cocoadevcentral.com/articles/000080.php>
<http://www.macdevcenter.com/pub/a/mac/2004/04/06/cocoa.html>
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden