key-value-coding

KVC string conversion not working for BOOL value.

Hey. I am reading in a string from a file and attempting to use the resulting string to set a BOOL property on an object using the KVC method -setValue:forKeyPath:. However, this breaks with an exception: -[NSCFString charValue]: unrecognized selector sent to instance 0x7fff711023b0. I'm guessing this is because BOOL is typedef'd from...

add<Key>Object vs insertNewObjectForEntityForName Core Data Relationships

Hi, Although I have a lot of experience in database development, I'm having a hard time conceptualizing linking relationships in Core Data. As I understand it, the many relationship is an NSSet attached to the one file. After reading the documentation, I've understood part of it and gotten it to work in the first import in my code bel...

Is it possible to bind to a property of an NSArrayController?

Basically in IB where there are the options "arrangedObjects", "selection" etc in the "Controller Key" drop down, is it possible to create my own entry in there to bind to? If possible this would allow me to bind certain text boxes to filtered aspects of the array held by the ArrayController (and furthermore use operators like @count on...

What's the KVC path for summing UIView subview properties?

I'm trying to calculate the total height of subviews in a UIScrollView: [self.subviews valueForKeyPath:@"[email protected]"]; But that throws the following: 'NSUnknownKeyException', reason: '[<NSConcreteValue 0x4b10170> valueForUndefinedKey:]: this class is not key value coding-compliant for the key size.' I've tried placing ...

Why use TT_RELEASE_SAFELY in three20 for iPhone?

#define TT_RELEASE_SAFELY(__POINTER) { [__POINTER release]; __POINTER = nil; } Why is does three20 consider it safe to assign an ivar to nil after releasing it? Is it unsafe to leave out the ivar = nil step? This is all I found: http://github.com/facebook/three20/commit/1b946f475fb28d60e0aafc9ef394050c642c3a5b#commitcomment-115517 I ...

Observing the editing property of a UITableViewController

Why can't I observe the editing property of an instance of UITableViewController? I'm using the following code: [self addObserver:self forKeyPath:@"editing" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:NULL]; And have implemented the method: - (void)observeValueForKeyPath...

iPhone key-value coding -- test for existence of key

Does iPhone key-value-coding have a way to test whether a class will accept a given key? That is, without implementing the valueForUndefinedKey: or setValue: forUndefinedKey: method of the target class, I want to be able to do something like this: if ([targetObject knowsAboutKey: key]) { [targetObject setValue: value forKey: key]; }...

Core Data: Two Different Ways to Access Attributes, Only One Works

For the following code, of the two comment preceded lines below, only the first works. NSManagedObject * Event = [NSEntityDescription insertNewObjectForEntityForName:str inManagedObjectContext:app.managedObjectContext]; //Work but strange [Event setValue:[NSNumber numberWithInt:buf4[v+h]] forKey:value]; //Error Event.value= [NSNumbe...

Add missing objects to create an ordered collection

Hi folks, The subject is vague because I'm not sure how to articulate in one sentence what I want. Here goes: I have an NSArray of NSDictionaries. Each NSDictionary represents one day of the calendar year. Each NSDictionary has a key "date" with a value of NSDate. There should be 365 NSDictionary items in the array. The dictiona...

Is there anything similar to AutoMapper for Objective-c?

AutoMapper for .Net lets you map from one type to another. Its most basic function is to create one type of class from another type of class by copying property values from type A that exist in type B (have matching names and types). Example: public class ClassA { public string StringProp { get; set; } public int IntProp { get...

Carry out action when multiple properties change

I have three different properties, x, y, z. If they all turn nil, I need to take an action, and if one of them is set to a value != nil, I have to carry out a different action. My current implementation is the following: @property (readonly) NSNumber *meta; + (NSSet *)keyPathsForValuesAffectingMeta { return [NSSet setWithObjects:@"x...