Newbie Q: Bindings
Newbie Q: Bindings
- Subject: Newbie Q: Bindings
- From: Tim Gray <email@hidden>
- Date: Thu, 25 May 2006 10:39:40 -0400 (EDT)
Hey, I'm trying to get my head around bindings a bit better and would appreciate any help.
I have a class which has a bunch of instance variables and methods to set and get those variables. The class also has a method which takes a file path in the form of an NSString and parses specific bytes in that file (its an IFF file) and populates the instance variables. A command line tool has been written which uses this class in a loop over the command line arguments (file names) and subsequently prints out some of the data in the IFF files. Everything works as expected.
My goal is to also develop a simple GUI program to view this data as well. I'm starting out with a program that just parses 1 file, but would like to end up with one that presents a whole directory of files in table format.
Ok, enough background. I did a mock up of the GUI program last night with two text fields and a button. The first text field is for a file path and the second displays one of the instance variables that is filled after parsing the file entered in the first field. The button is attached to my AppController class to a loadFile: method. The loadFile: method goes something like this:
-(void) loadFile {
NSString *filePath;
filePath = [filePathTextField stringValue];
myIFFFileInstance = [[IFFClass alloc] initWithFilePath: filePath];
\\ At this point myIFFFileInstance has a bunch of instance variables (like 30-40) that I would like to display in textfields...
[secondTextField setStringValue: \\
[myIFFFileInstance getInstanceVariableAsString]];
[myIFFFileInstance autorelease];
}
Hope that makes sense. This works fine. However, I'd like to it with bindings since it a) seems like less work, b) seems like the "modern" thing to do, and c) seems well suited to what I want to do since I have an instance which has a bunch of instance variables and I just want to display them all.
The question: I don't get how to use bindings. I've been through the tutorial (currency converter) and it seems to rely on a class method +(void)initialize. I get it in that case. Do I need to do something similar? Am I on the right path at all?
I know this is a simple question and if there's a good tutorial or something on the web that you can point me too, I'd be grateful. Thanks!
_______________________________________________
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