FROM : David Rocamora
DATE : Sun Apr 10 22:56:14 2005
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
DATE : Sun Apr 10 22:56:14 2005
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
| Related mails | Author | Date |
|---|---|---|
| David Rocamora | Apr 10, 19:58 | |
| Serge Meynard | Apr 10, 20:30 | |
| David Rocamora | Apr 10, 22:03 | |
| Shawn Erickson | Apr 10, 22:23 | |
| David Rocamora | Apr 10, 22:56 | |
| Serge Meynard | Apr 11, 00:00 | |
| David Rocamora | Apr 11, 00:34 | |
| Serge Meynard | Apr 11, 00:45 | |
| David Rocamora | Apr 11, 01:22 | |
| Serge Meynard | Apr 11, 01:59 | |
| mmalcolm crawford | Apr 11, 03:37 | |
| David Rocamora | Apr 11, 18:01 |






Cocoa mail archive

