The difference between these two lines of code is that the second is KVO compliant and the first isn't?
[person setValue:tempPerson.name forKey:@"name"];
person.name = tempPerson.name;
The reason I'm asking is because I need to update 60 attributes on over 500 objects, I don't want KVO notifications for more than a handful of attribut...
Put simply, is there a way to receive a general notification when any property in an Objective-C class is changed? I know I can use KVO to monitor particular property changes, but I have the need to call a particular method whenever any setProperty: message is sent to my class. I want to be able to receive a generic notification without ...
I have a NSTreeController which array is bound to a "items" (custom) property of an NSArrayController subclass.
As the tree controller is not bound to the selection of the NSArrayController I need to make sure to let the tree controller know that items has to be fetched after the selection of the array controller changes.
I have done t...
Hello!
I have a ViewController (with a MKMapView) which is pushed into, because of the NavigationController. So I have a NavBar with a "back" button.
Clicking that back-button, I get an error:
2010-01-11 18:05:35.273 TestApp[147:207] An instance 0x1758f0 of class MKUserLocation is being deallocated while key value observers are stil...
Is there any tool to log current observers of a given object, in the spirit of what "gdb info gc-roots" does? I found "gdb info gc-references" could do that (sort of) as a by-product of its original purpose, but that won't work with non garbage collected apps. Thanks!
...
I'm working on a little library that lets me do some basic key value coding w/ JSON objects. Say I have the following JSON array:
var data = { key1: "value1", key2: { nested1: 1, nested2: "wowza!" } };
And I have the following javascript function:
var setData = function(path, value) {
eval("data." + path + "= value;");
};
And ...
What do I need to do to update a tableView bound to an NSArrayController when a method is called that updates the underlying array? An example might clarify this.
When my application launches, it creates a SubwayTrain. When SubwayTrain is initialised, it creates a single SubwayCar. SubwayCar has a mutable array 'passengers'. When a ...
I previously posted this question as a comment on a related thread thinking it was simple. That thread is here:
http://stackoverflow.com/questions/670202/cocoa-binding-to-a-particular-item-in-an-array-controller/2082309#2082309
The questions relates to (and I'll more fully describe it here) a game I'm building to try and learn objec...
I have a class Test which has an array of Foos. I want to provide access to the Foos without exposing the ivar directly. I'm trying to make this KVC compliant (also to pave the way for KVO compliance). I have:
Test.h
@interface Test : NSObject
{
NSMutableArray *foos;
}
@property (readonly, copy) NSMutableArray *foos;
@end
Test....
I am trying to get the old and new values of the objects in my NSArrayController using KVO. The values passed into the change dictionary are nil though.
I have an NSArrayController and I have a class Model with a property name that use cocoa's @property and @synthesize to insure that they are KVO compliant.
@property (retain) NSString ...
I am having a crash in my CALayer subclass when I remove myself as an observer in -(void)dealloc:
- (void)dealloc {
[[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:@"showColorLabels"];
[colorLabel release];
[_color release];
[super dealloc];
}
An exception is thrown. It says that self has not been added as an...
[sessionController.currentSession addObserver:self
forKeyPath:@"sessionState"
options:(NSKeyValueChangeSetting)
context:NULL];
This doesn't seem to be working.
The class where this code goes knows about the sessionController and has access to th...
Say I'd like a mutable, unordered to-many relationship. For internal optimization reasons, it'd be best to store this in an NSMutableDictionary rather than an NSMutableSet. But I'd like to keep that implementation detail private.
I'd also like to provide some KVO-compliant accessors, so:
- (NSSet*)things;
- (NSUInteger)countOfThings;
-...
I'm extending UIButton with generic functionality to change certain appearance attributes based on the displayed title.
In order to do this, I need to detect and respond to changes in the "state" property. This is so I make sure the appearance is adjusted properly if the user has set different titles for different states. I assumed I ...
Hi!
Im trying to find a good way to handle memcache keys for storing, retrieving and updating data to/from the cache layer in a more civilized way.
Found this pattern, which looks great, but how do I turn it into a functional part of a PHP application?
The Identity Map pattern: http://martinfowler.com/eaaCatalog/identityMap.html
Than...
Is there a way to catch a "valueDidChange"-Event for a Textfield? oO
I've got a modalView with an UITextField.
When the UITextField is empty, the "Done"-Button in the NavigationBar should be disabled
and when there is Text entered, it should become enabled.
Right now the only way to accomplish this by using the "textFieldShouldReturn"...
I have an increase button and a decrease button, both of which affect a variable. The variable has a minimum and the decrease button will be disabled once that minimum is reached. Likewise for the maximum value of the variable. In my controller, I have two IBActions for both the increase and decrease actions, and two IBOutlets, in ord...
I have an NSScrollView subclass and I would like to update another NSView based on the current scroll position. I tried KVC-observing the value of [self horizontalScroller] but that never gets called.
// In awakeFromNib
[[self horizontalScroller] addObserver:self
forKeyPath:@"value"
...
Hi:
I have a ViewController creating an instance of a UIView, and then I register an observer with the instance, such that
logoAnimation = [[MainLogoAnimation alloc] init];
[logoAnimation addObserver:self forKeyPath:@"patrocinioDidLoad" options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:nil];
then, in the same...
When my application is closed, the main controller class removes itself as Observer from the model and then releases the model. Like this:
- (void)dealloc {
[theModel removeObserver:self
forKeyPath:@"myValue"];
[theModel release];
[super dealloc];
}
And right after that, the debugger says:
2010-04-29 ...