Skip navigation.
 
mlRe: Array Problems
FROM : David Rocamora
DATE : Sun Apr 10 22:03:07 2005

This is the code that has a full array in it.

- (void)createNewArtwork
{
   Artwork *newArtwork = [[Artwork alloc] init];
   [artworks addObject:newArtwork];
   [newArtwork release];
   NSLog(@"artworks is: %@", artworks);
}

When createNewArtwork adds a third object to the array NSLog says this:

artworks is: <CFArray 0x3524a0 [0xa01900e0]>{type = mutable-small,
count = 3, values = (
   0 : <Artwork: 0x3524b0>
   1 : <Artwork: 0x3b4d40>
   2 : <Artwork: 0x3b46d0>
)}


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];
}

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>
)}

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:

- (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?

Thanks again!

Dave

On Apr 10, 2005 2:30 PM, Serge Meynard <<email_removed>> wrote:
>
> It might help if you posted the significant sections of your code...
> How are you doing the load and save exactly?
>
> By the way, you should probably be using NSKeyedArchiver instead of
> NSArchiver.
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list      (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>

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