Re: Bindings problems...
Re: Bindings problems...
- Subject: Re: Bindings problems...
- From: "John C. Randolph" <email@hidden>
- Date: Thu, 24 Mar 2005 23:32:12 -0800
Looks like you have something observing "files" that isn't removing
itself as an observer when it goes away. Make sure you send -
removeObserver:forKeyPath: to anything you're observing in your -
dealloc method.
-jcr
On Mar 24, 2005, at 8:01 PM, Tom Birch wrote:
What I'm basically trying to do is add saveablity to my
application, such that when i add a new record or bunch of records,
or quit the app, it will write my changes to a file, and when I
open up it will load these changes. The app is not document-based,
it uses a normal controller (custom subclass of NSObject), an
NSObjectController to alias it, and an NSArrayController bound to
the selection of the NSObjectController
I have implemented saving fine, and I've been trying to implement
restoring of state, so in my awakeFromNib method of the controller
I have this:
if([[NSFileManager defaultManager] fileExistsAtPath:TBPODatabasePath])
{
[self willChangeValueForKey:@"files"];
[self setFiles:[NSUnarchiver
unarchiveObjectWithFile:TBPODatabasePath]];
[self didChangeValueForKey:@"files"];
}
with files being an NSMutableArray, and the accessor methods being
these:
- (id)files
{
return files;
}
- (void)setFiles:(id)newFiles
{
[newFiles retain];
[files release];
files = newFiles;
}
running through gdb i get...
Program received signal: "EXC_BAD_ACCESS".
on the call to [self setFiles:..]
when I just had "files = [NSUnarchiver...]" instead of setFiles,
the signal was triggered on the next line and files was loaded fine
(inspection with po showed everything).
the backtrace at the signal call was (excluding everything above
awakeFromNib)...
#0 0x908311ec in objc_msgSend ()
#1 0x90a92d98 in -[NSKeyValueObservationForwarder
observeValueForKeyPath:ofObject:change:context:] ()
#2 0x90a95ca8 in -[NSObject(NSKeyValueObserverRegistration)
_addObserver:forProperty:options:context:] ()
#3 0x90a95e80 in -[NSObject(NSKeyValueObserverRegistration)
addObserver:forKeyPath:options:context:] ()
#4 0x931afbe4 in -[_NSModelObservingTracker
_registerOrUnregister:observerNotificationsForModelObject:] ()
#5 0x931aff4c in -[_NSModelObservingTracker
startObservingModelObjectAtReferenceIndex:] ()
#6 0x931b0144 in -[_NSModelObservingTracker
startObservingModelObjectsAtReferenceIndexes:] ()
#7 0x931d4bc4 in -[NSArrayController
_selectObjectsAtIndexesNoCopy:avoidsEmptySelection:sendObserverNotific
ations:] ()
#8 0x931d4168 in -[NSArrayController
_arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask
:useBasis:] ()
#9 0x931d460c in -[NSArrayController setContent:] ()
#10 0x931dfd74 in -[NSArrayDetailBinder
_refreshDetailContentInBackground:] ()
#11 0x90a96434 in -[NSObject(NSKeyValueObservingPrivate)
_notifyObserversForKeyPath:change:] ()
#12 0x931d9758 in -[NSController
_notifyObserversForKeyPath:change:] ()
#13 0x931da0dc in -[NSController
observeValueForKeyPath:ofObject:change:context:] ()
#14 0x90a05d40 in -[NSObject(NSKeyValueObserverNotification)
didChangeValueForKey:] ()
#15 0x00443190 in -[Controller awakeFromNib] (self=0x545760,
_cmd=0x9086aa78) at /Users/froody/
if anyone has any ideas why this would be happening, I would love
to know!
cheers,
Tom
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden