tags:

views:

23

answers:

2

Hello,

I have a small little program I am working on just for fun. It's some kind of RPG Character-Generator. My class Character has some properties (NSNumber) for strength, dexterity and so on. Also I have TextFields to display these properties on the user interface.

@interface MyController : NSObject {

Character *rpgCharacter;
IBOutlet NSTextField *strength;
IBOutlet NSTextField *dexterity;
IBOutlet NSTextField *constitution;
IBOutlet NSTextField *intelligence;
IBOutlet NSTextField *wisdom;
IBOutlet NSTextField *charisma;

}

Now I am looking for an easy and maybe better way to bring the data from the class to the User Interface. At the moment I would just write a method who takes the data from rpgCharacter and sends it to the Textfields. That is not hard to do but maybe there is a better and more clever way to do this. I am thinking of some sort of databindung but I am not sure how to do it in this case.

+1  A: 

… maybe there is a better and more clever way to do this. I am thinking of some sort of databind[i]ng …

They even pretty much call it that.

Peter Hosey
+2  A: 

This is a standard feature of Cocoa. The binding mechanism allows you to tie properties and/or variables in your classes to controls that you lay out in Interface Builder. See http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaBindings/CocoaBindings.html

Jon Gotow