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 > editColumn:row:...:...: won't work (new to Cocoa)

editColumn:row:...:...: won't work (new to Cocoa)
Thread Tools
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Jun 16, 2002, 05:37 PM
 
Hi all. I can't get this NSTableView method to work! Can somebody help me?

The relevant part of my program looks a bit like this:

</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
(code to initialize empty tableViewSource earlier)

[tableViewSource addObject:@&quot;&quot;];
[aTableView reloadData];
[aTableView editColumn:0 row:0 withEvent:nil select:NO];
</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">(I've also tried it with select:YES which made no difference). What I'm trying to do here, is add a row to the (previously empty) NSTableView and then start editing the new (and only) row so that whatever the user types next appears in that row (first column).

Well all except the last line of code above appears to work. tableViewSource gets an empty string added, and the NSTableView gets a new row added. But when it comes to executing the last line nothing happens except and the following error is logged:

</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
&lt;date, time &amp; program&gt; *** Assertion failure in -[NSTableView editColumn:row:withEvent:select:], NSTableView.m:2207
&lt;date, time &amp; program&gt; Invalid parameter not satisfying: _lastSelectedRow == row
</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Can anyone explain what this error means, and how I go about fixing the problem?

Thanks in advance.

<small>[ 06-16-2002, 06:51 PM: Message edited by: Brass ]</small>
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Jun 16, 2002, 06:33 PM
 
From the docs:

</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">
The row at rowIndex must be selected prior to calling editColumn:row:withEvent:select:, or an exception will be raised.
</font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Yes, the docs are your friend. Sometimes, they are your only friend.

HTH,
F-bacher
     
Brass  (op)
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Jun 16, 2002, 06:41 PM
 
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by Ghoser777:
<strong>From the docs:

</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">
The row at rowIndex must be selected prior to calling editColumn:row:withEvent:select:, or an exception will be raised.
</font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Yes, the docs are your friend. Sometimes, they are your only friend.

HTH,
F-bacher</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Interesting. I did already try this (simply by guesswork) - I tried putting a line immediately before the edit method to select that row:

[aTableView selectRow:0 byExtendingSelection:NO];

It produced a different error so I removed it again. But at least now I know I'll have to put it back, and that the row selection error is the one I need to solve, not the table cell edit error. I'll have to report back if I have trouble solving that one.

By the way, could you tell me where that warning you quoted was documented? I'm all for using the documentation, but I'm not familiar with the doco yet. Perhaps if I could figure out which doco that is in, I can solve the error I'm having with row selection. That warning certainly wasn't obvious in the documentation I read on that method! Here is all the documentation that I know of for that method:

</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">
- (void)editColumnint)columnIndex rowint)rowIndex withEventNSEvent *)theEvent selectBOOL)flag

Edits the cell at columnIndex and rowIndex, selecting its entire contents if flag is YES. This method is invoked automatically in response to user actions; you should rarely need to invoke it directly. theEvent is usually the mouse event that triggered editing; it can be nil when starting an edit programmatically.

This method scrolls the receiver so that the cell is visible, sets up the field editor, and sends selectWithFrame:inView:editor:delegate:start:lengt h: and editWithFrame:inView:editor:delegate:event: to the field editor's NSCell object with the NSTableView as the text delegate.

See Also: - editedColumn, - editedRow </font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">

<small>[ 06-16-2002, 11:22 PM: Message edited by: Brass ]</small>
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Jun 16, 2002, 10:32 PM
 
Okay, let me rephrase: UPDATED documetnation is your friend I have the April's Beta Dev Tools installed, so my local docs are fairly recent. To get the most up to date ones, just go to apple's developer site and search for them (there's a link to the toc, but I'm too lazy to every bookmark it)

F-bacher
     
Brass  (op)
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Jun 16, 2002, 10:37 PM
 
heheh... okay, that makes sense. Thanks.
     
   
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 01:24 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