{"id":4582,"date":"2014-03-30T13:43:12","date_gmt":"2014-03-30T13:43:12","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/crash-on-nsbundle-mainbundle-loadnibnamedowneroptions-collection-of-common-programming-errors\/"},"modified":"2014-03-30T13:43:12","modified_gmt":"2014-03-30T13:43:12","slug":"crash-on-nsbundle-mainbundle-loadnibnamedowneroptions-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/crash-on-nsbundle-mainbundle-loadnibnamedowneroptions-collection-of-common-programming-errors\/","title":{"rendered":"Crash on [[NSBundle mainBundle] loadNibnamed:owner:options:]-Collection of common programming errors"},"content":{"rendered":"<p>I cannot figure this one out. I have a created a custom UITableViewCell in IB. As far as I can tell I have all the objects in the cell which are all UILabels wired up properly and everything builds without any errors. When I try to use the custom cell the app stops when I try to load the NIB. I&#8217;ve listed what I have in place for this below.<\/p>\n<p>Any help or hints or where to look to figure this one out would be appreciated.<\/p>\n<p>Thanks,<\/p>\n<p>John<\/p>\n<p>Here are my UITableViewCell interface and implementation methods. I am not sure I really needed to alloc init the labels. I tried it both ways&#8230;<\/p>\n<pre><code>\/\/  ArrivalTimesCell.h\n\n#import \n\n@interface ArrivalTimesCell : UITableViewCell {\n    IBOutlet UILabel *cityArrivalTimeLabel;\n    IBOutlet UILabel *optimumArrivalTimeLabel;\n    IBOutlet UILabel *arrivalAvoidTimesLabel;\n    IBOutlet UILabel *arrivalTimeNotSetLabel;\n\n}\n@property (nonatomic, retain)IBOutlet UILabel *cityArrivalTimeLabel;\n@property (nonatomic, retain)IBOutlet UILabel *optimumArrivalTimeLabel;\n@property (nonatomic, retain)IBOutlet UILabel *arrivalAvoidTimesLabel;\n@property (nonatomic, retain)IBOutlet UILabel *arrivalTimeNotSetLabel;\n\n@end\n\n\/\/  ArrivalTimesCell.m\n\n#import \"ArrivalTimesCell.h\"\n\n@implementation ArrivalTimesCell\n@synthesize arrivalTimeNotSetLabel, arrivalAvoidTimesLabel, optimumArrivalTimeLabel, cityArrivalTimeLabel;\n\n- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{\n    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];\n    if (self) {\n        arrivalTimeNotSetLabel = [[UILabel alloc] init];\n        arrivalAvoidTimesLabel = [[UILabel alloc] init];\n        optimumArrivalTimeLabel = [[UILabel alloc] init];\n        cityArrivalTimeLabel = [[UILabel alloc] init];\n    }\n    return self;\n}\n\n- (void)setSelected:(BOOL)selected animated:(BOOL)animated{\n    [super setSelected:selected animated:animated];\n\n}\n\n- (void)dealloc{\n    [super dealloc];\n    [arrivalTimeNotSetLabel release];\n    arrivalTimeNotSetLabel = nil;\n    [arrivalAvoidTimesLabel release];\n    arrivalAvoidTimesLabel = nil;\n    [optimumArrivalTimeLabel release];\n    optimumArrivalTimeLabel = nil;\n    [cityArrivalTimeLabel release];\n    cityArrivalTimeLabel = nil;\n}\n\n@end\n<\/code><\/pre>\n<p>Here is a portion of cellForRowAtIndexPath for the UITableView<\/p>\n<pre><code>\/\/  TripEditViewController.m\n\n#import \"ArrivalTimesCell.h\"\n\n@implementation TripEditViewController\n\n- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {\n\n    CellIdentifier = @\"ArrivalTimesCell\";\n    ArrivalTimesCell *cell = (ArrivalTimesCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];\n\n    if(cell == nil){\n        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@\"ArrivalTimesCell\" owner:nil options:nil];\n\n        for (id currentObject in topLevelObjects) {\n            if ([currentObject isKindOfClass:[UITableViewCell class]]) {\n                cell = (ArrivalTimesCell *) currentObject;\n                break;\n             }\n         }      \n    }\n\n\n    cell.cityArrivalTimeLabel.text = @\"Whatever\"\n    cell.arrivalAvoidTimesLabel.text = @\"Whatever\";\n    cell.optimumArrivalTimeLabel.text = @\"Whatever\";\n    cell.arrivalTimeNotSetLabel.text = @\"Whatever\";\n\n    return cell;  \n}\n<\/code><\/pre>\n<p>Program execution stops on the loadNibNamed line without any comment in the console. If I &#8220;step into&#8221; I get the following which I am not sure has anything to do with the cause of my crash but instead is the result of the nib not loading properly&#8230;<\/p>\n<blockquote>\n<p>2011-03-29 12:18:14.137 JetLogger[4565:207] <strong>* Terminating app due to uncaught exception &#8216;NSUnknownKeyException&#8217;, reason: &#8216;[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key cityArrivalTimeLabel.&#8217; *<\/strong> Call stack at first throw: ( 0 CoreFoundation 0x0111a5a9 <strong>exceptionPreprocess + 185 1 libobjc.A.dylib 0x0126e313 objc_exception_throw + 44 2 CoreFoundation 0x0111a4e1 -[NSException raise] + 17 3 Foundation 0x000ca677 _NSSetUsingKeyValueSetter + 135 4 Foundation 0x000ca5e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285 5 UIKit 0x0054e30c -[UIRuntimeOutletConnection connect] + 112 6 CoreFoundation 0x010908cf -[NSArray makeObjectsPerformSelector:] + 239 7 UIKit 0x0054cd23 -[UINib instantiateWithOwner:options:] + 1041 8 UIKit 0x0054eab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168 9 JetLogger 0x0004bf18 -[TripEditViewController tableView:cellForRowAtIndexPath:] + 699 10 UIKit 0x003c7b98 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634 11 UIKit 0x003bd4cc -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75 12 UIKit 0x003d28cc -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561 13 UIKit 0x003ca90c -[UITableView layoutSubviews] + 242 14 QuartzCore 0x02051a5a -[CALayer layoutSublayers] + 181 15 QuartzCore 0x02053ddc CALayerLayoutIfNeeded + 220 16 QuartzCore 0x01ff90b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310 17 QuartzCore 0x01ffa294 _ZN2CA11Transaction6commitEv + 292 18 QuartzCore 0x01ffa46d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99 19 CoreFoundation 0x010fb89b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION<\/strong> + 27 20 CoreFoundation 0x010906e7 __CFRunLoopDoObservers + 295 21 CoreFoundation 0x010591d7 __CFRunLoopRun + 1575 22 CoreFoundation 0x01058840 CFRunLoopRunSpecific + 208 23 CoreFoundation 0x01058761 CFRunLoopRunInMode + 97 24 GraphicsServices 0x01a081c4 GSEventRunModal + 217 25 GraphicsServices 0x01a08289 GSEventRun + 115 26 UIKit 0x00360c93 UIApplicationMain + 1160 27 JetLogger 0x00001ba8 main + 102 28 JetLogger 0x00001b39 start + 53 ) terminate called after throwing an instance of &#8216;NSException&#8217;<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>I cannot figure this one out. I have a created a custom UITableViewCell in IB. As far as I can tell I have all the objects in the cell which are all UILabels wired up properly and everything builds without any errors. When I try to use the custom cell the app stops when I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4582","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4582"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4582\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}