Re: Array Problems
Re: Array Problems
- Subject: Re: Array Problems
- From: Shawn Erickson <email@hidden>
- Date: Sun, 10 Apr 2005 13:23:55 -0700
On Apr 10, 2005, at 1:03 PM, David Rocamora wrote:
Here is the part that returns NSData of the archived object and it's data:
- (NSData *)dataRepresentationOfType:(NSString *)aType
{
NSLog(@"artworks: %@", artworks);
return [NSArchiver archivedDataWithRootObject:artworks];
}
What does the code look like that unarchives it?
Here is what NSLog says with the very same array as before when this
method is run:
artworks: <CFArray 0x3029b0 [0xa01900e0]>{type = mutable-small, count
= 1, values = (
0 : <Artwork: 0x330ab0>
)}
Can you clarify the above... it isn't clear if the log statement before archiving (archivedDataWithRootObject:) is the one listed above and hence your array doesn't contain what you expect when you do to archive it.
Looking closely at this now I notice that the addresses to the two
arrays show that they are actually two different arrays. The init
method appears to be creating two different arrays. I do not know why
this is happening. Here is the init code:
You are unarchiving an object so you will get back a different object graph then the one you archived but it will contain the same information as the one you archived (assuming the archive/unarchive process is correct) so expect different pointers to be listed in the NSLog output.... or am I not understand the framing of this question/concern?
Note if you want better information in you NSLog statements override -description in you Artwork class.
- (id)init
{
if ( self = [super init]) {
artworks = [[NSMutableArray alloc] init];
activeSet = artworks;
[self createNewArtwork];
}
}
It seems to be running init twice. Why is this happening? Is there a
way to design around this?
What class is this init code in? Who is calling this init?
You still have us mostly in the dark here... if you want help I suggest you list all code that touches artworks or walk thru that code that touches it with the debugger (set a break point at all lines that touch this variable).
-Shawn
_______________________________________________
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