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
0
votes
3 answers

Is there a more elegant way of finding unique NSDictionary keys within an NSArray?

Aim: To obtain an NSArray containing unique keys for given NSDictionary(s) using elegant code Example Code with Current Working Solution: NSArray *data = [[NSArray alloc] initWithObjects: [NSDictionary…
So Over It
  • 3,668
  • 3
  • 35
  • 46
0
votes
1 answer

KVC valueForKey return a __NSCFConstantString instead a __NSCFString

I use KVC in my projects. And, in one of my classes, I wrote the property : @property ( nonatomic, strong ) NSString *notes; I want to put a NSString object in that property : And before setting the value, I want to test the…
Chrstpsln
  • 765
  • 16
  • 31
0
votes
2 answers

understanding simple collection operators

I am reading Apple's Key Value Programming Guide. In the topic, Simple Collection Operators, I read: The following example returns the average value of the transaction amount for the objects in transactions: NSNumber…
Rounak
  • 613
  • 3
  • 8
  • 22
0
votes
1 answer

Create an NSManagedObject with the contents of a NSMutableDictionary (may have NSCFString in place of number)

I want to create an NSManagedObject with the contents of a NSMutableDictionary and Visa Versa. KVC doesn't work properly in NSManagedObject so i cant use [managedObject setValue:@"1" forKey:@"testKey"]; here managedObject has a property "NSNumber…
-1
votes
1 answer

About forKeyPath

I am following this tutorial to get to know KVC. stated in that tutorial the following [someObject.someProperty setText:@"This is a text"]; Using KVC: [self setValue:@"this is a text" forKeyPath:@"someObject.someProperty.text"] my questions…
Amrmsmb
  • 1
  • 27
  • 104
  • 226
-1
votes
1 answer

"this class is not key value coding-compliant for the key" error when shortening UI elements on Apple Watch Extension

I'm taking the watchOS2Sampler project available online and trying to experiment with adding a Picker to the "Gradation" Scene, which currently has two buttons at bottom and an image in the middle. My goal is to try and control an image's location…
Locksleyu
  • 5,192
  • 8
  • 52
  • 77
-1
votes
1 answer

IOS/Objective-C: Error Converting JSON to Object

I am trying to convert JSON array to object for display in table. I am able to capture JSON. However, when I try to turn into object, I get error shown below. There is definitely a property named "name" in object class. - (void)fetchedData:(NSData…
user1904273
  • 4,562
  • 11
  • 45
  • 96
-1
votes
1 answer

KVC Accessor Patterns for Trees

In this document, Apple describes Accessor Patterns for To-One and To-Many properties. To-Many properties cover Indexed and Unordered collections. Which brings me to the question: Is there a different Accessor Pattern for tree structures, or should…
insys
  • 1,288
  • 13
  • 26
-1
votes
1 answer

KVC release objs using valueForKeyPath?

I have a lot of objects named _Obj_1, _Obj_2, etc... And I want to release all. I'm using KVC. In particular to release all, i use: MyClass *obj = nil; for ( int i=1 ; i<=14; i++ ) { obj = [self valueForKeyPath:[NSString…
elp
  • 8,021
  • 7
  • 61
  • 120
-1
votes
2 answers

how can i access to UINavigationController with the string name

my app has the navController and at run time I have NSString *propertyName = @"navController"; and I know it is a type of UINavigationController how can i access to UINavigationController with the string name I might need to use…
ramo
  • 609
  • 2
  • 8
  • 14
-2
votes
1 answer

Setting CAEmitterLayer properties with KVC

I am attempting to to change properties on a CAEmitterLayer instance dynamically. I am making a call to setValue:forKey: like this: [self.mainViewController.mainView.spaceView.emitterLayer setValue:[NSNumber numberWithFloat:0]…
-2
votes
3 answers

Looping through an array of dynamic objects

I'm not really sure exactly how to describe what I want to do - the best I can do is provide some code as an example: - (void) doStuffInLoopForDataArray:(NSArray *)arr forObjectsOfClass:(NSString *)class { for ([class class] *obj in arr) …
GeneralMike
  • 2,951
  • 3
  • 28
  • 56
-3
votes
1 answer

Swift optional property using KVC causes crash

I found that using KVC in Swift causes many problems, especially with optional properties. Here is my specific problem: Here is a Class named Person. It has a normal property called age,and a Optional(Int) property called ageOptional. class Person:…
charlin
  • 5
  • 1
1 2 3
12
13