I've searched around StackOverflow for the optimal way to initialize and use a custom XIB UIView when working with a Storyboard, and all I've found was solutions similar to this one:
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self.subviews.count == 0){
SomeCustomView *viewFromNib = [[NSBundle mainBundle] loadNibNamed:@"SomeCustomView" owner:self options:nil].firstObject;
self.someProperty = viewFromNib.someProperty;
[self addSubview:viewFromNib];
}
return self;
}
But technically speaking, this would be adding a subview to the existing view on the Storyboard.
How would I simply just utilize the contents of the UIView without having to add it as a subview?
Something like this:
self = [[NSBundle mainBundle] loadNibNamed:@"SomeCustomView" owner:self options:nil].firstObject;
But when I do that, it returns BAD_EXEC
error.