• 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: saveDocument newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: saveDocument newbie question


  • Subject: Re: saveDocument newbie question
  • From: Neto <email@hidden>
  • Date: Tue, 20 Jun 2006 22:15:15 -0300

Alan,

I'll try you recent suggestion.

About my last e-mail:

The itens changed at myArray, but when I compare it with unchangedArray, the method consider them equal (unless I create a new item in myArray). I didn't print it, put I created an NSLog that informs "EQUAL" or "NOT EQUAL" using the output from the method bellow.

For some reason, this method works if I add or remove itens in myArray, but if I just edit existing itens in myArray, it considers them equal.

if (![editedArray isEqualToArray:myArray])
		{
			[self updateChangeCount: NSChangeDone];
			[editedArray release];
			editedArray = [[NSMutableArray alloc] initWithArray: myArray];
		}


Let me try your Enumerator suggestion.

Thanks a lot for helping!

n





On Jun 20, 2006, at 5:15 PM, Alan Smith wrote:

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."

_______________________________________________ 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
References: 
 >Excluding native file type from saveDocumentTo: accessory view. (From: Joshua Scott Emmons <email@hidden>)
 >saveDocument newbie question (From: Neto <email@hidden>)
 >Re: saveDocument newbie question (From: Andrew Merenbach <email@hidden>)
 >Re: saveDocument newbie question (From: "Alan Smith" <email@hidden>)
 >Re: saveDocument newbie question (From: Neto <email@hidden>)
 >Re: saveDocument newbie question (From: "Alan Smith" <email@hidden>)
 >Re: saveDocument newbie question (From: Neto <email@hidden>)
 >Re: saveDocument newbie question (From: "Alan Smith" <email@hidden>)

  • Prev by Date: What are your plans for WWDC?
  • Next by Date: Re: saveDocument newbie question
  • Previous by thread: Re: saveDocument newbie question
  • Next by thread: Re: saveDocument newbie question
  • Index(es):
    • Date
    • Thread