Questions tagged [kvc]

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.

References

193 questions
2
votes
1 answer

Objective-C - How does KVC work under the hood?

I am working with KVC and I am wondering how it works under the hood. Since it uses keys and values, I could assume that the self of each object holds a dictionary with keys = properties name and values = setters . So when I call [self…
BlackM
  • 3,927
  • 8
  • 39
  • 69
2
votes
3 answers

How can I use KVC Collection Operators for distinctUnionOfObjects in NSArray of NSDictionaries?

I want to get the Collection of a Specific Property from an array dictionary which has an array of values. Following is my array NSDictionaries: NSArray *arrGroupsFromServer= @[ @{@"Id": @"7d1021ba-e9be-40c1-a0a1-ad2a2d185b74",@"Name":…
BhavikKama
  • 8,566
  • 12
  • 94
  • 164
2
votes
1 answer

Swift: Boolean attributes and KVC mysteries

So I'm playing with this simple CoreData entity import CoreData class Figure: NSManagedObject { @NSManaged var approx: NSNumber? // Defined as Boolean type without default value } As you would expect, for a new figure, you get figure.approx #…
Arnaud
  • 17,268
  • 9
  • 65
  • 83
2
votes
1 answer

Can't get value from Google-Books JSON API

I'm using a bar code scanner to get data on a scanned book using the google books api. I successfully call the API and get a JSON object back. I'm trying to get the book title which follows the path items.volumeInfo.title. When I call valueForPath…
nhyne
  • 405
  • 1
  • 5
  • 18
2
votes
1 answer

Prefer property-accessor or KVC style for accessing Core Data properties

I have read the iOS-related chapters of Marcus S. Zarra's Core Data: Data Storage and Management for iOS, OS X, and iCloud (2nd edition) to great benefit. I am wondering about one aspect, though, where the book suggests a style that is different…
Drux
  • 11,992
  • 13
  • 66
  • 116
2
votes
1 answer

Detect if at least one property of object was modified

I have class with many strings and mutable arrays. All this objects represent form data. So if I modify textfield or add new photo to array I keep this data in my properties of object. How can I create validator that will check if some of that…
Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
2
votes
1 answer

Observing on NSMutableArray - Only Array accessors to be used

I have a mutable array which I have exposed in interface. I have also exposed the array accessors to modify the array. If any modification happens within the array, I would have to reset and re-calculate some data using KVO. To support KVO, I am…
Raj Pawan Gumdal
  • 7,390
  • 10
  • 60
  • 92
2
votes
3 answers

Restkit Mapping - No response descriptors match the response loaded

I'm new to RestKit and Objective C. I'm trying to retrieve data from a Web Service with RestKit. I have done the mapping but some how I'm getting the error that it could not find a match for the response. I am using Mapping without KVC as the JSON…
greenhatman
  • 76
  • 1
  • 7
2
votes
3 answers

NSMutableDictionary from NSMutableArray using KVC

I have an Input Array of Dictionaries : myArray = ( { name:"abc"; time:"6:00"; }, { name:"xyz"; time:"7:00"; }, . . ) I want Output Dictionary like this : myDictionary = { "6:00":( …
Bhavin
  • 27,155
  • 11
  • 55
  • 94
2
votes
1 answer

MagicalRecord sorting using by KVC

I used KVC until now to access object's properties. In my object i have a method like this: -(Address *)mainAddress { if (self.addresses != nil) { return [self.addresses anyObject]; //stub method } else { return nil; …
IgnazioC
  • 4,554
  • 4
  • 33
  • 46
2
votes
4 answers

Custom class NSObject not key value coding compliant

Possible Duplicate: Why is my object not key value coding-compliant? I'm having a dictionary and I want to add keys/values to a custom class, but i always get the error, that the class is not KVC compliant, but the Apple documents state that it…
matttrakker
  • 204
  • 3
  • 15
2
votes
2 answers

Remove UIColor CGColor - KVC warning

How to remove [[UIColor grayColor] CGColor] stupid warning? [self setValue: [[UIColor grayColor] CGColor] forKeyPath:[NSString stringWithFormat:@"_View_%@%d.layer.borderColor", i>=10?@"":@"0", i]]; Incompatible…
elp
  • 8,021
  • 7
  • 61
  • 120
2
votes
1 answer

How to return a primitive property value with CALayer's "+ (id) defaultValueForKey", etc?

So.. CALayer KVC "extensions" handle all the weirdo's... such as.. + (id) defaultValueForKey: (NSString*)key { return [key isEqualToString:@"borderColor"] ? (id)cgPINK : [super defaultValueForKey:key]; } And Apple's Docs…
Alex Gray
  • 16,007
  • 9
  • 96
  • 118
2
votes
1 answer

[myArray objectAtIndex:i].property in kvc

Anybody know the kvc key/key path fore this code [myArray objectAtIndex:i].property
Johnykutty
  • 12,091
  • 13
  • 59
  • 100
2
votes
1 answer

Core Data - Why does the object data stays fault even after accessing the property?

I'm using Core Data and i have a managed object that the description states its data is fault. I try to access a property with dot syntax but it's nil. If I use -[object valueForKey:@"key"]; the object fires fault and I get the correct value. from…
Or Arbel
  • 2,965
  • 2
  • 30
  • 40