key-value-coding

What do you need to implement to provide a Content Set for an NSArrayController?

Heys, I am writing something in Xcode. I use Core Data for persistency and link the view and the model together with Cocoa Bindings; pretty much your ordinary Core Data application. I have an array controller (NSArrayController) in my Xib. This has its managedObjectContext bound to the AppDelegate, as is convention, and tracks an entit...

Unexpected key-value behavior in a Core Data Context

If I create an array of strings (via key-value coding) containing the names of a Managed Object entity's attributes which are stored in the App Delegate the first time, I get an array of NSStrings without any problems. If I subsequently make the same call later from the same entry point in code, that same collection becomes an array of N...

How do I track down the source of a KVC exception: this class is not key value coding-compliant for the key toolbar?

I get this error when I try to run my app: 2010-04-29 13:49:01.355 MyApp[56123:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MyViewController 0x5112b10> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key toolbar.' MyViewController used to have an IBOutlet call...

How to set up a has-many relationship in Cocoa?

I'm building a (very) simple FTP app in Cocoa, and I need to store information on the different types of servers that are supported. So, I've created a ServerType class, which stores all of the relevant information about a single type of server. I then have a ServerTypes class which is designed to manage all of the ServerType classes tha...

iPhone OS: Why is my managedModelObject not complying with Key Value Coding?

Ok so I'm trying to build this stat tracker for my app and I have built a data model object called statTracker that keeps track of all the stuff I want it to. I can set and retrieve values using the selectors, but if I try and use KVC (ie setValue: forKey: ) everything goes bad and says my StatTracker class is not KVC compliant: valueF...

using KVO to update an NSTableView filtered by an NSPredicate

My UI is not updating when I expect it to. The application displays "projects" using a view similar to iTunes -- a source list on the left lets you filter a list (NSTableView) on the right. My filters update properly when they are examining any simple field (like name, a string), but not for arrays (like tags). I'm removing a tag f...

Setting up a "to-many" relationship value dependency for a transient Core Data attribute

I've got a relatively complicated Core Data relationship structure and I'm trying to figure out how to set up value dependencies (or observations) across various to-many relationships. Let me start out with some basic info. I've got a classroom with students, assignments, and grades (students X assignments). For simplicity's sake, we ...

how to udate window controls(NSTextField,NSCheckbox and etc) in binding manually

Hi, I am working on an application in which i need to store all the NSObject subclass properties into plist file and then allow users to store it and restore it. We call it profile and it can restore the saved state of all the controls/views on the window in my application. I have completed the storing/Restoring part, but the issue is ...

How can I write cocoa bindings as code instead of in the Interface Builder?

In my modell got an NSMutableArray that keeps track of a changing number of elements. In my view I got a NSTextField that shows the number of elements. The view gots unarchived from the nib file and alloc/inits the modell. Therefore it knowns about the modell and the contained array. I established the connection as follows. In the Inter...

Objective PHP and key value coding

Hi Guys. In some part of my code I need something like this: $product_type = $product->type; $price_field = 'field_'.$product_type.'_price'; $price = $product->$$price_field; In other words I need kind of KVC - means get object field by field name produced at the runtime. I simply need to extend some existing system and keep field nam...

Do you know of any Key-Value-Coding and Key-Value-Observing session videos on the net?

I know Apple is not the only ressource out there, and many people create great videos in conferences and presentations. If someone knows a great video or podcast on the topics KVC or KVO, please let me know. I would be glad about it! Edit: Changed Title so it's more clear this is indeed programming related. KVO / KVC / MVC != KFC ...

Does the type in this KVC validation method matter?

For example, in the docs a KVC-style validation method is implemented like this: -(BOOL)validateAge:(id *)ioValue error:(NSError **)outError They used id* as the type for ioValue. Since that's not part of the method signature, I wonder if it would hurt to do something like: -(BOOL)validateAge:(NSNumber *)ioValue error:(NSError **)out...

KVC with NSArrays of NSArrays

I have an array of arrays that I want to use KVC on (at least I think I do -- it seems like the most straightforward way) but I can't figure out how to create keypaths for individual array indexes. My array looks like this NSArray [ NSArray[0, 1, 2, 3], NSArray[4, 5, 6, 7], NSArray[8, 9, 10, 11] ] What I want to do is get the maximum...

UIScrollView not key value coding compliant for key view

Hi So following this SO question Here, i created two new sets of files: JCScrollViewController.m JCScrollViewController.xib JCKeyboard.xib In JCScrollViewController.xib i have just a scroll view, with the scrollView outlet of the .m file connected to it, the view outlet is connected to the View. The JCScrollViewController.m confor...

Cocoa Key-Value Coding and inverse relationship properties

I'm trying to figure out if the KVC mechanisms provide any sort of help when dealing with relationship properties which are inverse relationships of each other. I'll use the contrived and standard Department/Employee example. @interface Department : NSObject { NSMutableArray *employees; } @property (retain) NSMutableArray *employe...

Key-Value Coding and methods calling.

It's a question about good programming techniques with Cocoa. When you want to call a method on one property of your class, should you use KVC to get the receiver or just put the name of your property? Example, KVC: [[self property] myMethod]; Example, simple: [property myMethod]; Thanks! ...

Performance speed of KVO and NSNotifications?

Should I be afraid of using Key-Value Observations (KVO) and NSNotifications? I'm beginning to use them in my app, but I'm a little unfamiliar with the concept of something that could possibly be triggering an appwide call or automatically doing stuff, and a little afraid of the performance hit that such overhead could bring. Are my con...

Key Value Coding Primitives

I have some automatic de-serialization code that will set an object's properties using KVC. I need to add de-serialization support for primitives (int, double, float), but I am unable (or unsure of how) to use "setValue: forKey:" with primitives. The property lookups must be performed at runtime. Any ideas? Thanks. ...

KVC array: getters vs indexed accessors?

I'm confused by this: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#//apple_ref/doc/uid/20002174-178830-BAJEDEFB Supposing @interface Office : NSObject { NSMutableArray *employees; } What is the benefit of implementing the collection accessors? How is [anOffi...

Creating an Objective-C object that wraps another object with the same interface - KVC/KVO issues

I need to create an object in one class hierarchy that wraps an object from a different one. They both have very similar interfaces, and I'd like to automatically have my wrapper forward messages it doesn't recognize to its target in lieu of implementing its own properties. I got this to work using something like this: - (id)forwarding...