I've got an NSArrayController bound to a mutable array in my controller, which manages an array of my model objects. The array controller is bound to my UI. It works well.
Now I'm trying to manually observe when a value changes in my model in my controller class (basically I'm marking the changed model as "needsToSave" for later on, but...
I have created an Entity in CoreData that includes a Transformable attribute type implemented as an NSDictionary. The NSDictionary attribute only contains values of a custom class. The properties of the custom class are all of type NSString. The custom class complies with NSCoding implementing:
-(void)encodeWithCoder:(NSCoder*)coder;...
I am basically trying to implement an achievement tracking setup in my app.
I have a managedObjectModel class called StatTracker to keep track of all sorts of stats and I want my Achievement tracking class to be notified when those stats change so I can check them against a value and see if the user has earned an achievement.
I've tr...
My UI is not updating when I expect it to.
The application displays "projects" using a view similar to iTunes -- a source list on the left lets you filter a list (NSTableView) on the right. My filters update properly when they are examining any simple field (like name, a string), but not for arrays (like tags).
I'm removing a tag f...
I've got a relatively complicated Core Data relationship structure and I'm trying to figure out how to set up value dependencies (or observations) across various to-many relationships. Let me start out with some basic info. I've got a classroom with students, assignments, and grades (students X assignments). For simplicity's sake, we ...
Hi,
I am working on an application in which i need to store all the NSObject subclass properties into plist file and then allow users to store it and restore it. We call it profile and it can restore the saved state of all the controls/views on the window in my application.
I have completed the storing/Restoring part, but the issue is ...
I have 2 entities I want to link with KVO, one a single statTracker class that keeps track of different stats and the other an achievement class that contains information about achievements. Ideally what I want to be able to do is set up KVO by having an instance of the achievement class observe a value on the statTracker class and also ...
In my modell got an NSMutableArray that keeps track of a changing number of elements.
In my view I got a NSTextField that shows the number of elements.
The view gots unarchived from the nib file and alloc/inits the modell. Therefore it knowns about the modell and the contained array.
I established the connection as follows. In the Inter...
- (void)setFirstName:(NSString*)firstNameValue {
[self willChangeValueForKey:@"firstName"];
[firstName release];
firstName = firstNameValue;
[firstName retain];
[self didChangeValueForKey:@"firstName"];
}
Is that right? So the willChange... foobar didChange... block causes an KVO notification to fire?
...
I know Apple is not the only ressource out there, and many people create great videos in conferences and presentations.
If someone knows a great video or podcast on the topics KVC or KVO, please let me know. I would be glad about it!
Edit: Changed Title so it's more clear this is indeed programming related. KVO / KVC / MVC != KFC
...
I have a question regarding using KVO-compliant methods to insert/remove objects from an array. I'm working through Aaron Hillegass' Cocoa Programming for Mac OS X and I saw the following line of code (in the insertObject:inEmployeesAtIndex: method:
[[undoManager prepareWithInvocationTarget:self] removeObjectFromEmployeesAtIndex:index];...
Hey,
Is it possible to to subclass NSMutableSet? I need to do this in order to not retain objects contained in this set. The purpose todo that is to make an set of observers and those do not need to be retained.
Is it possible to do this or maybe you have an another solution.
Needles to say, I do know KVO but the pattern I have descri...
I've read over a ton of documentation and tutorials about KVO but I haven't found any that I've been able to abstract for my application. I have a table view that uses a custom UITableViewCell class to provide an interface for turning options on/off. The cell has a UISwitch that I would like to "bind" to my model's boolean properties. ...
Hi,
Let's say you have a custom control similar to NSSlider but with support for choosing a range of values, instead of a single value. The obvious choice of properties is minValue, maxValue, leftValue, rightValue, or however you wanna name them.
You'd probably also want to make sure that leftValue and rightValue always lay in between m...
I'm using Core Data and KVO to look for changes in values to trigger saves to the data store. I have a table view with search hooked up to NSFetchedResultsController. When the search changes, a new results controller is made on pressing the Search button. When the user selects an item in the results table view, then the user enters a det...
I'm trying to observe checkbox status and make appropriate changes in the app when checkbox status changes. In a window manager that manages the window with checkbox I have following observer setup:
- (void)awakeFromNib
{
[myCheckBox addObserver:self
forKeyPath:@"state"
options:(NSKeyValueObser...
Hi everyone,
I'm trying to wrap my head around NSNotification but can't seem to get it to work. Think I'm misunderstanding how to register for an notification.
I have a bool as a property in my connection manager class. At initialisation I authenticate with a few servers and check if I can access an external URL (App will mainly be use...
I thought home-cooked @property setters were supposed to look like this:
-(void) setFoo:(Foo *)newFoo {
// Safeguards
// ...
[self willChangeValueForKey:@"foo"];
// Switcheroo
// ...
[self didChangeValueForKey:@"foo"];
}
But I see a lot of code in blog posts by people who've been doing Cocoa a lot longer than I have, wh...
I have an NSArrayController linked to a Core Data object, set to Auto Rearrange Content and filtered by a predicate. All is well until I try to nullify a relationship and assign another. At that point, my application crashes and I receive the following error:
Cannot remove an observer
for
the key path "career.type"
from Object...
Should I be afraid of using Key-Value Observations (KVO) and NSNotifications? I'm beginning to use them in my app, but I'm a little unfamiliar with the concept of something that could possibly be triggering an appwide call or automatically doing stuff, and a little afraid of the performance hit that such overhead could bring.
Are my con...