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
1
vote
0 answers

Bind each row of NSTableView to separate property of object?

I have a main NSArrayController bound to an NSTableView with each row containing an instance of MyObject. MyObject has about 30 properties, but the NSTableView only has 5 columns (to show the most important properties). When a row (or more) is…
Trygve
  • 1,317
  • 10
  • 27
1
vote
2 answers

KVC and modern syntax

Did KVC pick up any of the features of objective-c literals a.k.a. 'modern objective-c' I'm wondering because it would be really handy if there were something far shorter, and more readable than [someObject setValue:someValue forKey:someKey];
Logicsaurus Rex
  • 3,172
  • 2
  • 18
  • 27
1
vote
0 answers

How to call a function exist in libobjc.A.dylib?

I'm studying how KVC works and I set a symbolic breakpoint _class_getVariable which function would be called when sending setValue:forKey: message to object. So I wrote this: extern Ivar _class_getVariable(Class cls, const char *name, Class…
Jintao Ou
  • 146
  • 1
  • 7
1
vote
1 answer

Accessing property in Cocoa AppDelegate (NSApplicationDelegate) from AppleScript

I have a very basic Cocoa application written in Xcode, and I'm trying to access a property of my application delegate with a simple AppleScript script: tell application "HelloWorld" set appDelegateProperty to property1 end tell The information…
1
vote
0 answers

Modifying NSMutableDictionary by key path

I have a NSDictionary with nested NSDictionary/NSArray (Generated through a JSON). I need to remove objects in multiple places according to some logic imposed on me. For instance lets say that the dictionary has some structure like: { "Array1" :…
Avba
  • 14,822
  • 20
  • 92
  • 192
1
vote
2 answers

Swift 2.0 Dictionary KVC-Extension

I am trying to implement a dictionary extension to conform to a KVC protocol: protocol KVCodeable { func valueForKeyPath(keyPath: String) -> AnyObject? } Reason for doing so, I'd like to be able to get values from either NSManagedObjects or…
Ron
  • 1,610
  • 15
  • 23
1
vote
1 answer

kvc get subview lastobject

I have a problem. first,I have a NSArray like this: (NSMutableArray *)currentCanMoveAndDeleteCellArray { NSInteger count = [self.contentCollectionView numberOfItemsInSection:0]; NSMutableArray *currentCells = [NSMutableArray…
alice jick
  • 11
  • 1
1
vote
4 answers

NSView with a KVC property in Swift

I have a custom NSView class defined as: class MyView: NSView { var someText: NSString override func didChangeValueForKey(key: String) { println( key ) super.didChangeValueForKey( key ) } // other stuff } What…
ericg
  • 8,413
  • 9
  • 43
  • 77
1
vote
1 answer

NSCollectionView does show nothing

I've tried to follow this guide: Quick Start for Collection Views using an NSImageView in the Collection View Item. Nothing shows up, neither if i set the image with a Image Well neither if i set the array via code. So i tried to do it…
1
vote
2 answers

Remove NSNull values in a KVC generated NSMutableArray

Here's a little test: NSDictionary * test = @ { @"centers" : @[ @{ @"id":@"12345", @"favorite":@NO }, @{ @"id":@"2345", @"favorite":@NO }, …
Zaphod
  • 6,758
  • 3
  • 40
  • 60
1
vote
2 answers

KVC without NSObject (NSPredicate)

I'm trying to use NSPredicate like so: let namePredicate = NSPredicate(format: "(username BEGINSWITH[c] $word)") if prefix == "@" { if countElements(word) > 0 { suggestionDatasource.users = (suggestionDatasource.users as…
Daniel van der Merwe
  • 1,570
  • 2
  • 10
  • 20
1
vote
1 answer

setValue:forKey crash with _sigtramp

The trace is like this Application received signal SIGSEGV Stack trace: #0 CoreFoundation 002BCE149F () #1 libobjc.A.dylib 00394F8C8B objc_exception_throw() #2 CoreFoundation …
Gary Lyn
  • 1,088
  • 9
  • 11
1
vote
2 answers

Key Value Coding for `description` property - Is this completely idiotic?

I am jumping into a codebase that I'm unfamiliar with to resolve a critical crash, so I'm interested in finding a quick fix for the problem below that I can patch and come back to refactor later. There is a strong coupling between the JSON structure…
edelaney05
  • 6,822
  • 6
  • 41
  • 65
1
vote
1 answer

How to set ModelKeyPath in InterfaceBuilder to be the opposite of a BOOL property

I am setting few menu items to enabled and/or hidden and it’s all based on one bool property. I do the set up with bindings and use the Model Key Path field. I would like to set up the opposite bool value of that property in some cases and I am not…
Mace
  • 201
  • 2
  • 5
1
vote
1 answer

setValuesForKeysWithDictionary on a managedObject gives compilation error in swift

I am trying a core data based app in swift, in which I am performing these steps: Retrieve data from plist Iterate through retrieved data During each iteration insert a managedObject in managedObjectContext Set values in inserted managedObject from…
Devarshi
  • 16,440
  • 13
  • 72
  • 125