key-value-observing

Using key paths in NSPredicates

I have an NSDictionary which contains (my custom) GTPerson objects. GTPerson has an NSMutableSet *parents attribute, on which I use @property and @synthesize. Out of my NSDictionary, I want to filter all the GTPerson objects which don't have any parents, i.e. where the count of parents is 0. I'm using the following code: NSPredicate ...

Observing self in Cocoa

In Cocoa, addObserver:forKeyPath:options:context: retains "neither the receiver, nor anObserver". Therefore I assume observing self is allowed; that is, it's perfectly valid to do something like [self addObserver:self forKeyPath...] As long as you remember to unregister self as an observer as the first thing in dealloc. Is this assump...

How to Key-Value-Observe the rotation of a CALayer?

I can access the value like this: NSNumber* rotationZ = [myLayer valueForKeyPath:@"transform.rotation.z"]; But for some reason, if I try to KV-observe that key path, I get a compiler error. First, this is how I try to do it: [myLayer addObserver:self forKeyPath:@"transform.rotation.z" options:0 context:nil]; The compiler tells me: ...

KVO rocks. Now how do I use it asynchronously?

I am sold on KVO but if used in the obvious way it is synchronous. I would like to use it in a situation where I am firing off many KVO messages in rapid succession and it is causing my app to grind to a halt as the KVO messages are handled. Can someone suggest an approach - perhaps using NSOperation or NSThread - that will work here. M...

key-value-coding a UIView's ivars

I'm interested in running some methods when my UIView is changed, either through a frame change or an affine transformation. My best idea is to do this by observing value changes for: myView.frame and myView.transform. However, the view portion of UIViews is not Key-Value complaint. Fortunatly the model portion of the view, the CAL...

KVC/KVO and bindings: why am I only receiving one change notification?

I'm seeing some quirky behaviour with Cocoa's KVC/KVO and bindings. I have an NSArrayController object, with its 'content' bound to an NSMutableArray, and I have a controller registered as an observer of the arrangedObjects property on the NSArrayController. With this setup, I expect to receive a KVO notification every time the array is ...

Observing NSTreeController's bound CoreData entities for insertion/removal

I am creating my own bindable custom treeview. For that I would like to observe NSTreeController for updates to its items' to-many-relationships. NSTreeController is bound to CD managed object context. Every depth level has its own CD Entity with parent/children/isLeaf properties. I need to maintain same hierarcy in the view (and order o...

How to observe managed object context

Hi, Whenever i make a change in the objects in the first tab of my application the updates are automatically upated in tab 2 becuase it uses a fetchedResultsController. Now i have a third tab that should also update itself, but how can i do that? I only have a nsmangedObjectContext in the third tab to get the appropriate data. How can ...

How do I bind a NSProgressIndicator to a property of a NSOperation?

I've got a window which reflects the status of an NSOperation. How should I bind the NSProgressIndicator to the NSOperation's progress-property? ...

KVO - problem retrieving object from storage and displaying for edition

Hi, I've a problem with KVO and I just can't find out what it is. I have a screen that can be used to edit or create a record. That record is represented by a model object that holds a number of variables of type NSString. The controller for that string has an instance variable to hold the model currently being worked on. When I open ...

Observing a UISlider's value - iPhone KVO

By default, when I observe the value of a UISlider, it only updates once, when the slider is clicked, not continuously, even thought that is the slider's setting. Is there a way to get the continuous value change of the slider? ...

Help with Key-Value-Observing.

I need a bit of help with KVO, I'm about half way there. What I'm trying to do is trigger a method when something in an Tree Controller changes. So I 'm using this code to register as a KVO. [theObject addObserver: self forKeyPath: @"myKeyPath" options: NSKeyValueObservingOptionNew context: NUL...

How can i tell if an object has a key value observer attached

if you tell an objective c object to removeObservers: for a key path and that key path has not been registered, it cracks the sads. like - 'Cannot remove an observer for the key path "theKeyPath" from because it is not registered as an observer.' is there a way to determine if an object has a registered observer, so i can do this if...

iPhone Key-Value Observer: observer not registering in UITableViewController

Hi Fellow iPhone Developers, I am an experienced software engineer but new to the iPhone platform. I have successfully implemented sub-classed view controllers and can push and pop parent/child views on the view controller stack. However, I have struck trouble while trying to update a view controller when an object is edited in a child ...

KVO on an NSCountedSet?

I'd like to monitor an NSCountedSet to see if its contents changes. Setting up KVO seems to compile but it's not being triggered. First question: can you observe a set? If so then is there something wrong with this message? [subViewA addObserver:subViewB forKeyPath:@"countedSet" options:0 context:NULL]; I'm really just trying to m...

Parameters from observeValueForKeyPath:ofObject:change:context:

I was wondering what the parameters from this method would return. - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context; In the documentation it says keyPath The key path, relative to ob...

Retrieving the information in the `change` dictionary from KVO.

The method - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { } has a parameter change which is a dictionary that contains information about the nature of the value change, how would I find out what was in this dictionary? ...

Stopping a loop.

As explained in my earlier question … This code … - (void)syncKVO:(id)sender { NSManagedObjectContext *moc = [self managedObjectContext]; [syncButton setTitle:@"Syncing..."]; NSString *dateText = (@"Last Sync : %d", [NSDate date]); [syncDate setStringValue:dateText]; NSEntityDescription *entityDescription = [NSEntit...

3 notifications instead of one

I'm developing simple MVC app in Cocoa/Objective-C. I have a strange issue (or misunderstanding) with notifications and KVO. I have AppController object in MainMenu.xib, hence I implement awakeFromNib method where I register for NSImageView changing its image property. I add self as an observer in the following way: // options:3 equals...

Cocoa Key Value Bindings: What are the explanations of the various options for Controller Key?

When I bind a control to an NSArrayController using Interface Builder, there are a variety of options under the "Controller Key" field in the bindings inspector. I understand what "arrangedObjects" is, and I semi-understand what "selection" is, but I'd love to see a really nice explanation of all the options and when to use each one. Th...