Re: NSUnarchiver: How to deal with locked file?
Re: NSUnarchiver: How to deal with locked file?
- Subject: Re: NSUnarchiver: How to deal with locked file?
- From: Stephan Ruggiero <email@hidden>
- Date: Mon, 6 Mar 2006 11:36:19 +0100
Hi,
BBB crashes with a file access error, so I do also think there's a
problem with the file being still open in some way.
NSArchiver still seems to be holding a hand on the file - even after
the archiveRootObject says YES on success.
The strange thing is that even if I wait for 3 seconds (should be
long enough, don't you think?), the file is still busy.
In the meantime I solved my problem by passing the data as a userInfo
object with the Notification. As it is just some bytes (that can be
coded as a plist) it works fine for me.
Anyhow: Many thanks for your response, I will surely get back to your
suggestion within the next coding projects!
best regards,
Stephan
Am 03.03.2006 um 01:17 schrieb Daniel Waylonis:
On Feb 24, 2006, at 11:57 PM, Stephan Ruggiero wrote:
Hello,
I have App AAA archiving a NSArray to a file using the following
code:
if ([NSArchiver archiveRootObject:array toFile:file]) {
[[NSDistributedNotificationCenter defaultCenter]
postNotificationName:@"AAA" object:@"newVersionAvailable"];
}
App BBB is registered to wait for that notification and then invokes:
if (array) {
[array release];
}
array = [[NSArray alloc] initWithArray:[NSUnarchiver
unarchiveObjectWithFile:file]];
But BBB crashes...
Maybe it is because "file" is busy and locked? I thought that
"archiveRootObject" returns "YES" after successfully writing the
data to disk? Is there any way to get around this? I tried waiting
3 secs before calling the reading process, but no change...
Or am I having another error?
Hi Stephan,
One thing might be that the file is not yet closed when you post
the notification. You might consider letting the autorelease pool
close up the NSArchiver by scheduling a method using
performSelector:withDelay:0 that then posts your notification.
Also, what is the crash for BBB?
Dan
-----------------------------------------------------------------
Dan Waylonis email@hidden
nekotech SOFTWARE
http://www.nekotech.com
650.964.2490 Voice / Fax
_______________________________________________
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