Key Value Coding is a mechanism for accessing an object’s properties indirectly, using strings to identify properties, rather than through invocation of an accessor method or accessing them directly through instance variables.
Questions tagged [key-value-coding]
390 questions
0
votes
3 answers
Key-Value-Coding with arbitrary methods, not only properties
It seems that -valueForKey: and -valueForKeyPath: work with arbitrary methods, not only with properties. This seems very convenient:
I first stumbled upon it in Interface Builder, and then made some experiments:
// Thing.h
#import…

MartinW
- 4,966
- 2
- 24
- 60
0
votes
2 answers
Explanation for assigning Objective-C NSNumber object to int variable?
Can anyone explain why this works in Objective-C? I would expect it to give an error since an object is being assigned to an int variable. I get that it does work, and this is great, but I am missing why this is allowed?
int i = [NSNumber…

Topher
- 498
- 5
- 17
0
votes
1 answer
NSPopUpButtonCell error when embedded in an NSTableColumn that is bound
When binding cells in my NSTableView of type NSPopUpButtonCell I got an error
[ valueForUndefinedKey:]: this class is not key value coding-compliant for the key value.
The reality is that I am simply after the contents of the…

Jackie Lambert
- 1
- 2
0
votes
2 answers
Response Descriptor with unexpected value for a keyPath
I have a response descriptor that maps a response using a keyPath such as @"rootKey.subKey", where rootKey is a dictionary and subKey is an array. e.g.
{rootKey:{subKey:[@"object1", @"object2",...,]}}
But some times I get the following…

Shuaib
- 11
- 1
- 3
0
votes
0 answers
Obtaining class of key at runtime
I have a class with below interface:
@interface MyData : NSObject
@property (readwrite, strong) NSString *urlToParse;
@property (readwrite, strong) MappingElement *titleElement;
- (instancetype)initWithPlist:(NSString *)plistPath;
Its…

Devarshi
- 16,440
- 13
- 72
- 125
0
votes
1 answer
observeValueForKeyPath called multiple times
I have a custom container navigation. I have a diary view controller and a diary detail view controller. When user clicks on a picture in diary, it goes to diary detail using cycleFromViewController:toViewController method as described in the Apple…

noobsmcgoobs
- 2,716
- 5
- 32
- 52
0
votes
1 answer
Objective C collection operators - Getting the average 'array count' in a 2D array
I'm trying to use KVC collection to get the average count of arrays in a collection. In other words, my data structure looks like this @[ @[...], @[......], @[..] ] and I am trying to average the count of the internal arrays.
I could do it the old…

Sean Danzeiser
- 9,141
- 12
- 52
- 90
0
votes
1 answer
valueForKey not working within for loop in swift
In my class I have below method which returns an array of names of all properties in it:
func getListOfProperties() -> Array
{
var count : UInt32 = 0
let classToInspect = NSURL.self
let properties : UnsafePointer…

Devarshi
- 16,440
- 13
- 72
- 125
0
votes
1 answer
Key-Value coding with auto-synthesized properties on NSObject subclass: respondsToSelector returns NO for all property accessors?
I have a simple NSObject subclass with some properties
@interface MyThing : NSObject
@property (nonatomic, copy) NSString *aString;
//... and so on
@end
But when I try to use key/value coding to set my properties via a dictionary:
+…

ray
- 1,966
- 4
- 24
- 39
0
votes
1 answer
Parsing unnamed JSON arrays within array with Restkit
I have the following JSON body containing arrays of decimal numbers within arrays:
( I. )
{
"decimals":
[
[
18000.00,
18000.00
]
],
}
I have created a class DecimalEntity with helper attribute "number"…

Vladimír Slavík
- 1,727
- 1
- 21
- 31
0
votes
2 answers
KVC get lastPathComponent from string which is the property of object
I have e.g. 5 MyFile objects in my NSArray. Each of these 5 objects has property path.
MyFile *myFile ...;
NSString path = myMyFile.path;
So using KVC I can get the properties form all my 5 objects in the array:
NSArray *folders = [[PNFolder…

Matrosov Oleksandr
- 25,505
- 44
- 151
- 277
0
votes
1 answer
NSDictionary - need to obtain value for key subelement
I have created an NSDictionary named "myData"
which contains the following JSON response:
{
listInfo = (
{
date = 1392157366000;
dateAsString = "02/11/2014 22:22:46";
id = 6;
address = 542160e0000c; …

Native_Mobile_Arch_Dev
- 777
- 6
- 20
0
votes
1 answer
simple app with error " this class is not key value coding-compliant for the key "
I create a simple iPhone app with xib file, and add one button to the view. create a IBOutlet to connect with it. each time, I launch it, it will crash. the full error message is as below:
2014-05-03 08:10:19.742 test[1435:a0b] * Terminating app due…

user3599379
- 27
- 7
0
votes
0 answers
KVC compliance error on self referencing relationship in Core Data
I have a Person entity in Core Data model. I want to create a "friends" relationship conceptually which essentially is a self-referencing relationship (ie. expect friends fetch to return a list of "Person" objects. However, there is NO inverse…

appledevguru
- 105
- 9
0
votes
1 answer
How to get the object with the lowest property value from an NSArray
I have an array of CLLocation objects.
If I use
CLLocation *bestLocation = [locations valueForKeyPath:@"@min.horizontalAccuracy"];
I'm getting the lowest horizontalAccuracy value. But I want the OBJECT that contains the lowest value, so that I…

Jan
- 2,462
- 3
- 31
- 56