Skip navigation.
 
mlRe: Array Problems
FROM : Shawn Erickson
DATE : Sun Apr 10 22:23:55 2005

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

Related mailsAuthorDate
mlArray Problems David Rocamora Apr 10, 19:58
mlRe: Array Problems Serge Meynard Apr 10, 20:30
mlRe: Array Problems David Rocamora Apr 10, 22:03
mlRe: Array Problems Shawn Erickson Apr 10, 22:23
mlRe: Array Problems David Rocamora Apr 10, 22:56
mlRe: Array Problems Serge Meynard Apr 11, 00:00
mlRe: Array Problems David Rocamora Apr 11, 00:34
mlRe: Array Problems Serge Meynard Apr 11, 00:45
mlRe: Array Problems David Rocamora Apr 11, 01:22
mlRe: Array Problems Serge Meynard Apr 11, 01:59
mlRe: Array Problems mmalcolm crawford Apr 11, 03:37
mlRe: Array Problems David Rocamora Apr 11, 18:01