I am using a view-based table, and I want to create an outlet for an element in a cell view. I cannot get the outlet to connect though... it's always nil
.
Specifically, I have a NSProgressIndicator
in a table cell and want to manipulate it in code.
Here's what I have so far:
I have created a subclass of NSTableView
, with the corresponding outlet property:
@interface MyTableCellView : NSTableCellView
@property IBOutlet NSProgressIndicator *myProgressIndicator;
@end
@implementation MyTableCellView
-(void)awakeFromNib
{
// _myProgressIndicator is nil!
}
@end
And I have set the custom class in the nib. The existing NSTableCellView
is replaced with MyTableCellView
via the dropdown.
At this point, some observations:
If I Ctrl+Click and drag the progress indicator to connect this outlet, it is not shown.
Likewise, if I try to Ctrl+Click and drag the progress indicator using the assistant editor, I can only connect to the property via binding. It doesn't recognize this as a valid outlet.
However this outlet IS shown on the sidebar, with a warning that it doesn't exist:
I know MyTableCellView
is being used. Breakpoint on awakeFromNib
confirms this, and confirms that _myProgressIndicator
is nil
.
This is a sandbox project, with barely more than what I've described.
SO, how do I access this progress indicator from code?
Choose iOS -> Source -> Cocoa Touch Class. Name the class TableCiewController and make it a subclass of UITableViewController. Go to the TableViewController. swift file and declare the following array.
I don't believe you should do it that way; instead:
reloadData
(or better reloadDataForRowIndexes:columnIndexes:
).Therefore you should only need an outlet to the table view to do this and any modification of the table view's cell objects should be done within the table view delegate and/or data source methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With