• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Array Problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Array Problems


  • Subject: Re: Array Problems
  • From: David Rocamora <email@hidden>
  • Date: Sun, 10 Apr 2005 16:56:14 -0400

Sorry for being unclear. I am convinced that my trouble is in
MyDocuments init method. Here is init from MyDocument's
implementation:

- (id)init
{

	if (self = [super init]) {
		artworks = [[NSMutableArray alloc] init];
		activeSet = artworks;

		[self createNewArtwork];

		NSNotificationCenter *nc;

		nc = [NSNotificationCenter defaultCenter];
		//notifier to update sheet
		[nc addObserver:self
			   selector:@selector(noteToUpdateSheet:)
				   name:@"AMUpdateSheet"
				 object:nil];
		//notifier for OK on sheet
		[nc addObserver:self
			   selector:@selector(noteToUpdateArtwork:)
				   name:@"AMUpdateData"
				 object:nil];
		//note to add artist name from picker
		[nc addObserver:self
			   selector:@selector(noteToUpdateArtistName:)
				   name:@"AMUpdateArtistName"
				 object:nil];
		//note to add owner from picker
		[nc addObserver:self
			   selector:@selector(noteToUpdateOwnerName:)
				   name:@"AMUpdateOwnerName"
				 object:nil];
		//note to search it up
		[nc addObserver:self
			   selector:@selector(noteToSearch:)
				   name:@"AMSearch"
				 object:nil];


		[self updateUI];

    }
    return self;
}

I believe this is the problem because it is run two times. Once when
the program is started and then right after makeWindowControllers is
run. This creates two artworks arrays at different addresses.

Here is the run log:

// The first init:

2005-04-10 16:49:02.778 ArtManager[658] artworks is: <CFArray 0x3029b0
[0xa01900e0]>{type = mutable-small, count = 1, values = (
	0 : <Artwork: 0x32fc60>
)}

// The second init (notice the different addresses 0x3029b0 and 0x3540b0):

2005-04-10 16:49:03.075 ArtManager[658] artworks is: <CFArray 0x3540b0
[0xa01900e0]>{type = mutable-small, count = 1, values = (
	0 : <Artwork: 0x3486a0>
)}

//Here we add an object to the second array:

2005-04-10 16:52:01.335 ArtManager[658] artworks is: <CFArray 0x3540b0
[0xa01900e0]>{type = mutable-small, count = 2, values = (
	0 : <Artwork: 0x3486a0>
	1 : <Artwork: 0x36f450>
)}

//Here I click File->Save and it saves the first array that has not
been modified:

2005-04-10 16:52:17.889 ArtManager[658] artworks: <CFArray 0x3029b0
[0xa01900e0]>{type = mutable-small, count = 1, values = (
	0 : <Artwork: 0x32fc60>


Is there a better place to put the code that initializes the array?

Thanks,
Dave
 _______________________________________________
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

  • Follow-Ups:
    • Re: Array Problems
      • From: mmalcolm crawford <email@hidden>
    • Re: Array Problems
      • From: Serge Meynard <email@hidden>
References: 
 >Array Problems (From: David Rocamora <email@hidden>)
 >Re: Array Problems (From: Serge Meynard <email@hidden>)

  • Prev by Date: Re: progress bar on sheet
  • Next by Date: Re: progress bar on sheet
  • Previous by thread: Re: Array Problems
  • Next by thread: Re: Array Problems
  • Index(es):
    • Date
    • Thread