Where'd my sounds go?
Posted
by Dane Man
on Stack Overflow
See other posts from Stack Overflow
or by Dane Man
Published on 2010-06-15T01:58:08Z
Indexed on
2010/06/15
2:02 UTC
Read the original article
Hit count: 327
In my Row class I have the initWithCoder method and everything restored in that method works fine, but only within the method. After the method is called I loose an array of sounds that is in my Row class. The sounds class also has the initWithCoder method, and the sound plays fine but only in the Row class initWithCoder method. After decoding the Row object, the sound array disappears completely and is unable to be called.
Here's my source for the initWithCoder:
- (id) initWithCoder:(NSCoder *)coder {
...
soundArray = [coder decodeObjectForKey:@"soundArray"];
NSLog(@"%d",[soundArray count]);
return self;
}
the log shows the count as 8 like it should (this is while unarchiving). Then the row object I create gets assigned. And the resulting row object no longer has a soundArray.
[NSKeyedArchiver archiveRootObject:row toFile:@"DefaultRow"];
...
row = [NSKeyedUnarchiver unarchiveObjectWithFile:@"DefaultRow"];
So now whenever I call the soundArray it crashes.
//ERROR IS HERE
NSLog(@"%d",[[row soundArray] count]);
Help please (soundArray is an NSMutableArray).
© Stack Overflow or respective owner