key-value-coding

Cocoa Key Value Bindings: What are the explanations of the various options for Controller Key?

微笑、不失礼 提交于 2019-12-02 19:38:58
When I bind a control to an NSArrayController using Interface Builder, there are a variety of options under the "Controller Key" field in the bindings inspector. I understand what "arrangedObjects" is, and I semi-understand what "selection" is, but I'd love to see a really nice explanation of all the options and when to use each one. The list includes: selectionIndexes, selectionIndex, selectedObject, sortDescriptors, etc. I haven't been able to find a good explanation of these options. I'm having trouble with a button that's bound to target > selection, so I'm hoping a much deeper

NSUnknownKeyException for existing and non-mistyped key

这一生的挚爱 提交于 2019-12-02 17:43:45
问题 I'm getting the following output: *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSManagedObject 0x21016610> setValue:forUndefinedKey:]: the entity MyEntity is not key value coding-compliant for the key "aBooleanKey".' The code that runs before I get the output is the following: self.name = [managedObject valueForKey:@"name"]; self.language = [managedObject valueForKey:@"language"]; self.ownerID = [managedObject valueForKey:@"ownerID"]; // the following line

NSUnknownKeyException for existing and non-mistyped key

给你一囗甜甜゛ 提交于 2019-12-02 10:49:27
I'm getting the following output: *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSManagedObject 0x21016610> setValue:forUndefinedKey:]: the entity MyEntity is not key value coding-compliant for the key "aBooleanKey".' The code that runs before I get the output is the following: self.name = [managedObject valueForKey:@"name"]; self.language = [managedObject valueForKey:@"language"]; self.ownerID = [managedObject valueForKey:@"ownerID"]; // the following line is the scope of the problem: self.aBooleanKey = [[managedObject valueForKey:@"aBooleanKey"] boolValue]

pyobjc indexed accessor method with range

送分小仙女□ 提交于 2019-12-01 22:29:38
问题 I'm trying to implement an indexed accessor method for my model class in Python, as per the KVC guide. I want to use the optional ranged method, to load multiple objects at once for performance reasons. The method takes a pointer to a C-array buffer which my method needs to copy the objects into. I've tried something like the following, which doesn't work. How do I accomplish this? @objc.accessor # i've also tried @objc.signature('v@:o^@') def getFoos_range_(self, range): return self._some

pyobjc indexed accessor method with range

Deadly 提交于 2019-12-01 21:07:00
I'm trying to implement an indexed accessor method for my model class in Python, as per the KVC guide . I want to use the optional ranged method, to load multiple objects at once for performance reasons. The method takes a pointer to a C-array buffer which my method needs to copy the objects into. I've tried something like the following, which doesn't work. How do I accomplish this? @objc.accessor # i've also tried @objc.signature('v@:o^@') def getFoos_range_(self, range): return self._some_array[range.location:range.location + range.length] Edit : I finally found the type encodings reference

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

倖福魔咒の 提交于 2019-11-30 21:47:49
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. The Controller Key pop-up menu is a way to help you discover what keys the controller (typically a NSArrayController, NSObjectController or a NSTreeController) presents. The best example is the selection key of NSArrayControllers, which contains the set of selected objects. What is confusing is the NSObjectController presents a 'selection' key too, although the controller can control only a single object (therefore the selection = the object). I agree that it is not

Objective-c KVC: Collection Accessor Patterns for To-Many Properties, how can I use this to enhance my code?

試著忘記壹切 提交于 2019-11-30 15:23:57
问题 I was reading :Collection Accessor Patterns for To-Many Properties, but I'm not sure where can I or should I use this. Can someone please point out some scenarios that I can use Collection Accessor Patterns for To-Many Properties to make my code better or make my code writing easier? 回答1: The collection accessor patterns that you were reading about improve the way key value coding works with collections like NSArray, NSDictionary, etc. If you implement them in your own classes, your classes

Objective-c KVC: Collection Accessor Patterns for To-Many Properties, how can I use this to enhance my code?

女生的网名这么多〃 提交于 2019-11-30 14:10:09
I was reading : Collection Accessor Patterns for To-Many Properties , but I'm not sure where can I or should I use this. Can someone please point out some scenarios that I can use Collection Accessor Patterns for To-Many Properties to make my code better or make my code writing easier? The collection accessor patterns that you were reading about improve the way key value coding works with collections like NSArray, NSDictionary, etc. If you implement them in your own classes, your classes can be used with KVC just like the standard collection classes. For example, maybe you've got a Flight

KVC string conversion not working for BOOL value

孤街浪徒 提交于 2019-11-30 10:20:59
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 char. Is there a way around this? Thanks! When setting a BOOL property using KVC, you need to pass an NSNumber object. What you could do in your case is pass [NSNumber numberWithBool:[myString boolValue]] . That should fix your crash. I am catching the

Key-Value Coding (KVC) with Array/Dictionary in Swift

喜你入骨 提交于 2019-11-30 09:48:16
Is it possible to key-value code (KVC) with native Swift data structures such as Array and Dictionary? Key-Value coding is still available for NSFoundation structures within Swift, just like in Objective C. For example, this is valid: var nsarray: NSArray = NSArray() // Fill the array with objects var array: NSArray = nsarray.valueForKeyPath("key.path") But this is invalid: var swiftarray: Array = [] // Fill the array with objects var array = swiftarray.valueForKeyPath("key.path") // Invalid, produces a compile-time error It seems that KVC on native Swift objects is just not supported. Here's