Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Comparing NSTableView items

Comparing NSTableView items
Thread Tools
Grizzled Veteran
Join Date: Jun 2002
Status: Offline
Reply With Quote
Apr 28, 2004, 12:57 PM
 
Hi guys,

Another question from me . So I have a NSTableView, and I am adding items to it by doing this:

[code]- (void)addSnippetid)sender
{
TagSnippet *newSnippet = [TagSnippet snippet];
[newSnippet setTitle:NSLocalizedString(@"Untitled", nil)];[listOfSnippets addSnippet:newSnippet];
[snippetTableView reloadData];
[snippetTableView selectRow[listOfSnippets count] - 1) byExtendingSelection:NO];
[snippetTableView editColumn:0 row[listOfSnippets count] - 1) withEvent:nil select:YES];
}

This basically add an item into my NSTableView with the title Untitled, and highlights it for editing. What I want to do is, if in the table view is a title that is the same as the one just entered, bring up a dialog or sheet.

I've looked on Mamasam, and can't find anything about comparing items. Same with the docs of NSTableView. Just a quick overview of my code above:

newSnippet is my snippet object.
listOfSnippets is a NSMutableArray which holds all my snippets.
snippetTableView is the actual table view which holds all snippets.

Any ideas/code really appreciated,
Oliver
     
Addicted to MacNN
Join Date: Nov 2002
Location: Seattle, WA
Status: Offline
Reply With Quote
Apr 28, 2004, 02:21 PM
 
for (i=0;i<[list count];i++)
if ([[newSnippet title] isEqualToString:[[list objectAtIndex:i] title]]) [self showConfirmationDialog];

you should probably also make sure the two snippets both have titles before calling isEqualToString
     
Grizzled Veteran
Join Date: Jun 2002
Status: Offline
Reply With Quote
Apr 28, 2004, 04:43 PM
 
Hey,

Thanks the code worked great.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:28 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2