kvc Questions
2
Solved
I'm using Xcode 10.0 with swift 4.2 to learn about Key Value Coding from "Cocoa programming for OSX"
I'm asked to create a simple class, which is a subclass of NSObject. The codes below:
import C...
8
Solved
I have
data =
{
'first': {
'number': 1,
'text': 'Ya.'
},
'second': {
'number': 10,
'text': 'Da.'
}
};
And I really want to access it like:
number = data['first.number'];
Actually in ...
Nopar asked 16/7, 2013 at 17:50
2
Solved
I was very happy to find Swift 3's implementation of #keyPath(), which will eliminate typos and enforce at compile time that the key path actually exists. Much better than manually typing Strings.
...
Eikon asked 8/2, 2017 at 20:15
1
Solved
I have updated my code to swift 4 in Xcode 9. Before that it was working fine. But now AVplayer is crashing at observers below is the code where it is crashing.
addObserver(self, forKeyPath: "pla...
3
I am learning how to use KVO. I created two classes, Truck and Driver as shown below.
the Truck class has a textfield and a button, the text should contain the current truck speed, and when the bu...
Doormat asked 11/8, 2017 at 18:12
6
I'm trying to understand some theory part in Objective C related to KVC. Following is the example I've done.
I'm having class call Cookie and it has a property like below
@property NSString *name...
Opportina asked 4/3, 2015 at 8:4
1
Solved
My team has decided that new files should be written in swift, and I am seeing an odd problem with using KVC in an Objective-C object to set a property on a Swift object.
My Objective-C sets a pro...
Generalize asked 3/3, 2016 at 21:59
2
Solved
Is there a way to construct an NSPredicate so the following array can be filtered by average score larger than, say, 5?
NSArray *objs = @[
@{@"scores":@[@3, @5, @2]},
@{@"scores":@[@5, @2, @8, @9]...
Codeclination asked 3/5, 2013 at 12:38
3
Solved
I'm using KVC to serialize an NSObject and attempt to save it to NSUserDefaults, which is giving me an Attempt to insert non-property value when I try to store my NSDictionary.
Following are the p...
Turfman asked 24/2, 2012 at 2:28
1
Solved
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, w...
1
This is a mystery:
I'm invoking setPrimitiveValue:forKey: on an NSManagedObject. The key is a legit, persistent, modeled attribute of the object. However, setPrimitiveValue:forKey: fails, often se...
Lifework asked 18/12, 2013 at 20:58
1
Solved
In a nsobject you have a property "keyPath" you want to observe itself and you use
[self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:nil];
Does the above lin...
Postremogeniture asked 6/4, 2014 at 6:11
2
Solved
I recently read some documentation and some blog entries about Key-Value Coding and found it extremely useful. I want to utilize it for my case, but I haven't been successful so far.
In my case, I...
Ceramic asked 28/5, 2013 at 9:15
3
Solved
Which of the following is faster and why?
CGFloat sum = 0;
for (UIView *v in self.subviews)
sum += v.frame.size.height;
or
CGFloat sum = [[self.subviews valueForKeyPath:@"@sum.frame.size.heig...
Plica asked 2/5, 2013 at 11:50
1
Solved
Let's assume we have an object of type person, which has a property called name.
Person *p;
[p setValue:@"John" forKey:@"name"];
This works very nicely. What I want to do is dig deeper. Say the ...
Notepaper asked 23/4, 2013 at 7:16
1
Solved
I can't figure out what @UnionOfObjects offers that a simple valueForKey: or valueForKeyPath: can't do.
Apple docs:
The @unionOfObjects operator returns an array containing the distinct
object...
Reaves asked 28/8, 2012 at 23:22
6
Solved
I've got an object of type id and would like to know if it contains a value for a given keyPath:
[myObject valueForKeyPath:myKeyPath];
Now, I wrap it into a @try{ } @catch{} block to avoid excep...
Lotze asked 19/12, 2011 at 12:44
1
Solved
I created an NSView subclass that has a float property and I'd like to set it in Interface Builder. In the User Defined Runtime Attributes section the only suitable Type is Number. But if I want to...
Vicinal asked 15/5, 2012 at 19:8
3
Solved
Before I switched to iOS development via Monotouch I played around a bit with ObjectiveC. Ever since one thing has been on my mind "Key Value Coding" (KVC). I have never understood what it is good ...
Hemimorphite asked 25/2, 2012 at 21:8
1
© 2022 - 2024 — McMap. All rights reserved.