 |
 |
objectValueForTableColumn Crashes Program
|
 |
|
 |
|
Mac Elite
Join Date: Jul 2001
Location: Evansville, IN
Status:
Offline
|
|
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)tableView  NSTableView *)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. 
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status:
Offline
|
|
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
|
|
identifier responded to po w/ <nil>
exercise responded with <Exercise: 0x1220760>
Why is my identifier not getting a value?
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jan 2000
Location: Los Altos, CA, USA
Status:
Offline
|
|
</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/ <nil>
exercise responded with <Exercise: 0x1220760>
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
|
|
</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/ <nil>
exercise responded with <Exercise: 0x1220760>
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?
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jan 2000
Location: Los Altos, CA, USA
Status:
Offline
|
|
</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)tableView  NSTableView *)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 @"Unknown table view";
}</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jul 2001
Location: Evansville, IN
Status:
Offline
|
|
</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)tableView  NSTableView *)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 @"Unknown table view";
}</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?
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jan 2000
Location: Los Altos, CA, USA
Status:
Offline
|
|
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
|
|
</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?
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|