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 > objectValueForTableColumn Crashes Program

objectValueForTableColumn Crashes Program
Thread Tools
Mac Elite
Join Date: Jul 2001
Location: Evansville, IN
Status: Offline
Reply With Quote
Jul 2, 2002, 12:01 AM
 
Greetings,

I am working on an application with an NSTableView that will display 5 columns of data. I have set up my dataSource, but this one function keeps crashing the program on launch, and I am clueless as to why. It gives me the error that it is looking up an unknown key: (null)

</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">- (id)tableViewNSTableView *)tableView
objectValueForTableColumn: (NSTableColumn *)tableColumn
row: (int)row
{
NSString *identifier = [tableColumn identifier];
Exercise *exercise = [exercises objectAtIndex: row];

return [exercise valueForKey:identifier];
}
</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">If anyone could assist me with this, I'd be appreciative.
Justin Williams
Chicks Really Dig Me
AIM - iTikki [NEW AND IMPROVED!]
http://www.tikkirulz.com
     
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Jul 2, 2002, 12:23 AM
 
I'd guess that excercise doesn't have a key for the identifier. Set a breakpoint in the function and debug your app. When it breaks, use the Console tab of the debugger and type
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">po identifier
po excercise</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">This will show you what identifier you're trying to look up and what keys are defined.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
Mac Elite
Join Date: Jul 2001
Location: Evansville, IN
Status: Offline
Reply With Quote
Jul 2, 2002, 04:43 PM
 
identifier responded to po w/ &lt;nil&gt;
exercise responded with &lt;Exercise: 0x1220760&gt;

Why is my identifier not getting a value?
Justin Williams
Chicks Really Dig Me
AIM - iTikki [NEW AND IMPROVED!]
http://www.tikkirulz.com
     
Fresh-Faced Recruit
Join Date: Jan 2000
Location: Los Altos, CA, USA
Status: Offline
Reply With Quote
Jul 2, 2002, 05:14 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 Justin W. Williams:
<strong>identifier responded to po w/ &lt;nil&gt;
exercise responded with &lt;Exercise: 0x1220760&gt;

Why is my identifier not getting a value?</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Assuming the table column is made with Interface Builder:

Have you set the identifer within Interface Builder? (That would be a different field than the column title...)

If you created the table column manually, you'd want to [yourTableColumn setIdentifier:@"column5"];

or something like that...
     
Mac Elite
Join Date: Jul 2001
Location: Evansville, IN
Status: Offline
Reply With Quote
Jul 2, 2002, 05:22 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 Brad Brack:
<strong> </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 Justin W. Williams:
<strong>identifier responded to po w/ &lt;nil&gt;
exercise responded with &lt;Exercise: 0x1220760&gt;

Why is my identifier not getting a value?</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Assuming the table column is made with Interface Builder:

Have you set the identifer within Interface Builder? (That would be a different field than the column title...)

If you created the table column manually, you'd want to [yourTableColumn setIdentifier:@"column5"];

or something like that...</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">I set my Data Source to point to the NSTableView in my Window. Is this what you are talking about. If not, my answer to your question would most likely be no. What do I do?
Justin Williams
Chicks Really Dig Me
AIM - iTikki [NEW AND IMPROVED!]
http://www.tikkirulz.com
     
Fresh-Faced Recruit
Join Date: Jan 2000
Location: Los Altos, CA, USA
Status: Offline
Reply With Quote
Jul 2, 2002, 07:28 PM
 
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">
<strong>I set my Data Source to point to the NSTableView in my Window. Is this what you are talking about. If not, my answer to your question would most likely be no. What do I do?</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">i) In Interface Builder, double click on your NSTableView, then click once on the table column's header cell - the header should now turn blue.
ii) Do a 'Show Info' (Menu: Tools:Show Info or Command-Shift-I)

You should now see a the show info pane with NSTableColumn specific fields, e.g. Column Title and Identifier (among others)
The title corresponds to what is displayed in the column header (which you can also enter by double clicking the table column header cell)

The Identifier corresponds to what you will get from tableView: objectValueForTableColumn: row:
when you call
<strong>[tableColumn identifier];</strong>

iii) Type in your identifier that your Exercise variable will accept

note 1: you may have to hit return or tab after filling out the identifier- sometimes Interface Builder does not keep what you typed in

note 2: you may want to encapsulate your objectValueForTableColumn code in case you have muliple NSTableViews using this as a datasource
e.g.
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">- (id)tableViewNSTableView *)tableView
objectValueForTableColumn: (NSTableColumn *)tableColumn
row: (int)row
{
NSString *identifier = [tableColumn identifier];
if (tableView == myExerciseTableView) {
Exercise *exercise = [exercises objectAtIndex: row];
return [exercise valueForKey:identifier];
}
else return @&quot;Unknown table view&quot;;
}</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">
     
Mac Elite
Join Date: Jul 2001
Location: Evansville, IN
Status: Offline
Reply With Quote
Jul 3, 2002, 12:25 AM
 
</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 Brad Brack:
<strong>[QUOTE]
[qb]
note 2: you may want to encapsulate your objectValueForTableColumn code in case you have muliple NSTableViews using this as a datasource
e.g.
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">- (id)tableViewNSTableView *)tableView
objectValueForTableColumn: (NSTableColumn *)tableColumn
row: (int)row
{
NSString *identifier = [tableColumn identifier];
if (tableView == myExerciseTableView) {
Exercise *exercise = [exercises objectAtIndex: row];
return [exercise valueForKey:identifier];
}
else return @&quot;Unknown table view&quot;;
}</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif"></strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Keeps telling me that myExerciseTableView is undeclared. I am assuming this is pointing to my IBOutlet id myExerciseTableView I have setup in my Controller class. Am I right?
Justin Williams
Chicks Really Dig Me
AIM - iTikki [NEW AND IMPROVED!]
http://www.tikkirulz.com
     
Fresh-Faced Recruit
Join Date: Jan 2000
Location: Los Altos, CA, USA
Status: Offline
Reply With Quote
Jul 3, 2002, 02:59 AM
 
Originally posted by Justin W. Williams:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif"><strong>Keeps telling me that myExerciseTableView is undeclared. I am assuming this is pointing to my IBOutlet id myExerciseTableView I have setup in my Controller class. Am I right?</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">yes- the myExerciseTableView is your IBOutlet- sorry for not making that clear. Also, you'll have to do the connection in Interface Builder. Is your data source not the controller? If it isn't, then you won't be able to access that IBOutlet directly (and thus you may not want to encapsulate as I suggested, or else you'll have to do some more connections...)
     
Mac Elite
Join Date: Jul 2001
Location: Evansville, IN
Status: Offline
Reply With Quote
Jul 3, 2002, 04:47 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 Brad Brack:
<strong>Originally posted by Justin W. Williams:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif"><strong>Keeps telling me that myExerciseTableView is undeclared. I am assuming this is pointing to my IBOutlet id myExerciseTableView I have setup in my Controller class. Am I right?</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">yes- the myExerciseTableView is your IBOutlet- sorry for not making that clear. Also, you'll have to do the connection in Interface Builder. Is your data source not the controller? If it isn't, then you won't be able to access that IBOutlet directly (and thus you may not want to encapsulate as I suggested, or else you'll have to do some more connections...)</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">I have a Controller class that has all my IBOutlet declarations + methods to calculate some values & open/close sheets.

My DataSource class has all my tableView stuff.

Should I consolidate all this stuff into one?
Justin Williams
Chicks Really Dig Me
AIM - iTikki [NEW AND IMPROVED!]
http://www.tikkirulz.com
     
   
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 09:55 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