NSTableView registerNib:forIdentifier: - multiple IDs in a single NIB
NSTableView registerNib:forIdentifier: - multiple IDs in a single NIB
- Subject: NSTableView registerNib:forIdentifier: - multiple IDs in a single NIB
- From: Alex Kac <email@hidden>
- Date: Thu, 14 Jan 2016 15:38:35 -0700
I have a NIB with two views that I want to use depending on circumstances. I call one “weatherCell” and one “weatherCellNarrow”.
I register it like this:
- (NSString*)identifierForWeatherCell {
return _narrowView ? @"weatherCellNarrow":@"weatherCell";
}
********
nib = [[NSNib alloc] initWithNibNamed:@"WeatherCell" bundle:nil];
[self.outlineView registerNib:nib forIdentifier:self.identifierForWeatherCell];
********
WeatherCell* weatherCell = [outlineView makeViewWithIdentifier:self.identifierForWeatherCell owner:nil];
IB images:
<https://www.dropbox.com/s/o8g5y3t7rrf1whs/Screenshot 2016-01-14 15.33.13.png?dl=0>
<https://www.dropbox.com/s/ll9n526nw7e9pju/Screenshot 2016-01-14 15.33.28.png?dl=0>
<https://www.dropbox.com/s/yjidhle3lxx2aai/Screenshot 2016-01-14 15.33.22.png?dl=0>
The problem is that no matter the order of views in IB, the only one that works is “weatherCell” and not the narrow one - it just comes back nil. Reading the docs and stack overflow, I can’t seem to get a good answer to if this should work or not (having multiple cellViews in one NIB). Based on my initial tests…I’d say no. However the fact that ONE of them does work makes me curious if anyone else has ever gotten it to work.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden