FROM : Alan Smith
DATE : Tue Jun 20 22:15:15 2006
Neto,
Have you printed out the arrays? You said: "But if I just edit an
existing item, both arrays remains the same..." Do you mean your code
never executes or that the items really don't ever change? If it's the
first one I suggest you use a NSEnumerator to iterate through one
array and compare it against the other. If you then get to an object
that isn't the same you can updateChangeCount. Like this:
- (void)checkArray:(id)sender
{
NSEnumerator *enumerator = [editedArray objectEnumerator];
id object;
while (object = [enumerator nextObject];)
{
if (! [uneditedArray containsObject: object])
{
//code to updateChangeCount
[self updateChangeCount: NSChangeDone];
break;
}
else
{
[self updateChangeCount: NSChangeCleared];
break;
}
}
[uneditedArray release];
uneditedArray = [[NSMutableArray alloc] initWithArray: editedArray];
}
There. That will go through the array that is displayed in the table
checking it with the duplicate. If there is an object in the
editedArray that isn't in the uneditedArray then it will
updateChangeCount to set as needing saving. If they' re the same then
it sets the document as not needing saving. That should do it.
Peace, and good luck, Alan
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"Don't waste your life doing things others have already done."
DATE : Tue Jun 20 22:15:15 2006
Neto,
Have you printed out the arrays? You said: "But if I just edit an
existing item, both arrays remains the same..." Do you mean your code
never executes or that the items really don't ever change? If it's the
first one I suggest you use a NSEnumerator to iterate through one
array and compare it against the other. If you then get to an object
that isn't the same you can updateChangeCount. Like this:
- (void)checkArray:(id)sender
{
NSEnumerator *enumerator = [editedArray objectEnumerator];
id object;
while (object = [enumerator nextObject];)
{
if (! [uneditedArray containsObject: object])
{
//code to updateChangeCount
[self updateChangeCount: NSChangeDone];
break;
}
else
{
[self updateChangeCount: NSChangeCleared];
break;
}
}
[uneditedArray release];
uneditedArray = [[NSMutableArray alloc] initWithArray: editedArray];
}
There. That will go through the array that is displayed in the table
checking it with the duplicate. If there is an object in the
editedArray that isn't in the uneditedArray then it will
updateChangeCount to set as needing saving. If they' re the same then
it sets the document as not needing saving. That should do it.
Peace, and good luck, Alan
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"Don't waste your life doing things others have already done."
| Related mails | Author | Date |
|---|---|---|
| Joshua Scott Emmon… | Jun 18, 05:12 | |
| Neto | Jun 18, 23:29 | |
| Andrew Merenbach | Jun 19, 00:19 | |
| Alan Smith | Jun 19, 16:45 | |
| Neto | Jun 19, 17:10 | |
| Alan Smith | Jun 19, 19:03 | |
| Joshua Scott Emmon… | Jun 20, 02:59 | |
| Kevin Hoctor | Jun 20, 04:15 | |
| Neto | Jun 20, 06:39 | |
| Alan Smith | Jun 20, 22:15 | |
| Neto | Jun 21, 03:15 | |
| mmalcolm crawford | Jun 21, 03:40 |






Cocoa mail archive

