key-value-coding

Implementing a KVO/Bindings-Compliant Bridge-Pattern in Cocoa

Hi folks, I'm trying to implement a simple object bridge in cocoa where the bridge object acts as a kvo/bindings-compliant drop in for some arbitrary other NSObject instance. Here is my problem (more details in the code below): A bridge object acts as a drop in for a Person-Object, with an NSString* property called name and an Address...

Cocoa bindings problem; bound table columns don't show any data, no errors in console

I'm having trouble converting my Cocoa project from a manually-synched interface model to a bindings model so that I don't have to worry about interface glue code. I followed the CocoaDevCentral Cocoa Bindings tutorial to make sure that I had covered all the bases, but things aren't working correctly. I have a master-detail interface, ...

Weird bindings issue

I'm trying to use a browser view with bindings to represent some data and I'm getting an error message: 2008-11-11 17:22:28.636 BrowserViewTest[18269:813] Cocoa Bindings: Error accessing value for key path arrangedObjects.projects of object <NSTreeController: 0x1321e0>[object class: BillingCode] (from bound object <NSBrowser: 0x126930...

Observing an NSMutableArray for insertion/removal

A class has a property (and instance var) of type NSMutableArray with synthesized accessors (via @property). If you observe this array using: [myObj addObserver:self forKeyPath:@"theArray" options:0 context:NULL]; And then insert an object in the array like this: [[myObj theArray] addObject:[NSString string]]; An observeValueForKey...

Case-insensitive KVC in Cocoa?

Hi everyone, I'd appreciate some feedback on a particular approach I'm thinking of using. The scenario is below. I have an object (lets call it MObject) that has a number of properties, say, x and y coordinates, height and width. The properties are named according to the KVC guidelines (MObject.x; MObject.height, etc). My next task, is...

How do I attatch a Key value pair to a UIView on iPhone?

Hiya, When I started iPhone development, I read somewhere that it's possible to attach a key value pair to a UIView. I understood that all UIViews could be used as dictionaries to store any data you may want to attatch to them to prevent unnecessary subclassing. However, I've searched everywhere to find the reference and tried to implem...

Using KVC to generate SQL?

Hi, I wonder if it is possible to use KVC to generate SQL. I'm doing a light ORM; I wanna do something like this (pseudocode): for key in object.getKeys sql = sql + formatField(key,objet.value[key]); and get: INSERT INTO Table (Field1) VALUES (1); Is this possible in Objective-C? ...

How do I make the value binding of NSTokenField supply an NSString?

I have replaced an NSTextField with an NSTokenField so that I can perform some auto-completion. The value of the NSTextField was bound to a NSString attribute of a controller class. Now that I have changed the NSTextField to an NSTokenField the value has changed to an NSArray. How do I make the NSTokenField value binding be an NSString...

Key-Value-Observing a to-many relationship in Cocoa

I am trying to get key-value-observing to work for an NSMutableArray. Below is the .h file for MyObservee, the observed class: @interface MyObservee : NSObject { @private int someValue; @private NSMutableArray *someArray; } @property (readwrite,assign) int someValue; - (NSMutableArray *)someArray; @end The class MyObserver im...

On Objective-C/Cocoa Key-Value coding and arrays...

I'm trying to work out the "correct" way to handle populating an array with key-value coding for an iPhone app. I've come up with something that works, but it's fairly hackish. Basically I'm parsing an XML document into a set of code-generated models. Let's assume the XML is of this format: <foo> <bar> <item name="baz" />...

What does "Controller Key" mean in Interface Builder > Inspector > Bindings?

I can't find in the Docs where they explain all those fields and what they mean. Especially "Controller Key" is not clear to me. ...

KVC compliance for numbers in NSManagedObject subclass (CoreData)

I'm trying a basic test of sorting an NSManagedObject subclass. I set up a basic subclass "TestClass" with two attributes: stringField and numberField. They use the standard Obj-C 2.0 accessor protocol: @interface TestClass : NSManagedObject @property (retain) NSString *stringField; @property (retain) NSNumber *numberField; @end @imple...

Cocoa binding to a particular item in an array controller

Is it possible using NSArrayController to bind a NSTextField's value to a particular item in the array? In particular, I want to bind to a property on the first item in the array, and show nothing if the array is empty. Using arrangedObjects.command shows just "(" -- presumably it's trying to show a multi-line string with comma-separat...

Limiting the number of objects in NSArrayController

I'm trying to create some kind of "Top 25" list in my app. I've used NSPredicate to filter the contents of the array controller but I want to limit the number of the results to just 25 objects. How could I do that? ...

How to add an object to a programatically bound NSMutableArray?

I have an NSDocument which has the following structure: @interface MyDocument : NSDocument { NSMutableArray *myArray; IBOutlet NSArrayController *myArrayController; IBOutlet MyView *myView; } @end I instantiate the NSArrayController and the MyView in MyDocument.xib, and have made the connections to the File's Owner (MyDoc...

Exception When Setting the Nib Name field in Interface Builder

Hey Guys, I'm trying to load a view controller from a nib in Interface Builder. My basic setup is this: MainWindow.xib contains: All the usual stuff, the app delegate instance, the Window etc. A UINavigationController which has a UIViewController as it's Root View Controller. The nib name of the UIViewController is set to the name of ...

Is it possible to have a binding that combines more than one key path?

Lets say I have an object which has a quantity value. Also, I have an array controller which holds an array of these objects. Furthermore, I have a table which has a percent of total column (i.e. the given row's quantity's percentage of the sum of the quantities for all rows), which needs to be populated with the proper value via bindi...

Should "to-many" relationships be modelled as properties?

After reading the Key-Value Coding Programming Guide, the Key-Value Observing Programming Guide and the Model Object Implementation Guide, as well as reading many StackOverflow entries on the topic and experimenting with various modelling scenarios, I feel like I have a good grasp on how to model my data. I end up using declared propert...

Update bound dictionary based on NSTextFieldCell's edited value

I'm working on porting some ancient code (10.2 era) from NSCoding/plist based archiving to using Core Data. I have an NSOutlineView with a custom NSTextFieldCell. The outline view is bound to an NSTreeController to provide the data. The bindings model looks like this: NSTreeController: Managed Object Context -> Controller.managedObjec...

NSUnknownKeyException, KVC compliance code not working

the following piece of code which gets successfully built and also seems alright to me but doesn't work... mind that i am new to key value coding and your help will be greatly appreciated... in table view delegate didSelectRowAtIndexPath: method here the categoriesList is a simple table with 5 entries NSUInteger row = [indexPath row]; ...