Home Installation Release notes Language Reference Support Downloads Tutorials FutureBasic 5 Links

Working with nibs - Multicolumn TableView

Multicolumn tableviews require a bit more preparation because the tableview's data source methods need to be able to identify which column is which. Columns are identified by... guess what?... their 'Identifier'.

1. Launch Xcode and create a new User Interface/Window
 

2. Set the window's minimum content size (we do this to avoid any movement of the table view if the window is resized too small)
 

3. Show the Objects panel and drag a tableview onto the window
 

4. Resize the enclosing scrollview to fit the window and set its autoresizing springs and struts to grow/shrink with the window
 

5. Set the tableview's columns to '4'.


 

6. While we're in the Attributes Inspector, we may as well set the tableview's tag value to '1'

 

• Set column attributes •

7. Repeatedly click on the tableview's first column area until the column highlights and "Table Column" appears at the top of the Attributes Inspector

 
Hm, can be a bit awkward that. An easier way to select a column is to show the document outline and expand the view hierarchy down to the tableview


 

8. With the first column selected, enter its title


 

9. Now switch to the Identity Inspector and enter an identifier


 

10. In the Size Inspector, set the column width to 100


 

11. Repeat steps 8-10 for the other three columns

Voila!


 

12. Save and close the nib file
 

13. Create a new FB file

void local fn CreateTableData
CFMutableArrayRef array
CFMutableDictionaryRef dict
CFIndex row, col
CFStringRef identifier, string
array = fn TableViewData(1)
for row = 0 to 20
dict = fn MutableDictionaryWithCapacity(0)
for col = 0 to 3
identifier = fn StringWithFormat( @"Col%ld", col )
string = fn StringWithFormat( @"Cell %ld,%ld", row, col )
MutableDictionarySetObjectForKey( dict, string, identifier )
next col
MutableArrayAddObject( array, dict )
next row
TableViewReloadData(1)
end fn
 

void local fn BuildWindow
nibwindow 1, @"Window"
fn CreateTableData
end fn
 

fn BuildWindow  

HandleEvents

 

14. Save the FB file to the same folder as the nib and run it