I'm using a Kal Calendar in my app. However my app crashes when the Kal ViewWillAppear is called. Here is my code.
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
KalViewController *calendar = [[KalViewController alloc] init];
[self.navigationController pushViewController:calendar animated:YES];
calendar.dataSource = self;
[calendar reloadData];
self.tabBarController.delegate = self;
}
I used breakpoints and my app is crashing at:
[calendar reloadData];
Here is the error message from the debugger
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
* First throw call stack:
(0x2088012 0x156ae7e 0x203bb6a 0x203ba20 0x10c1b 0x1ca08 0x11088 0x282103 0x28242b 0x297fad 0x29889b 0x2989b9 0x298a45 0x39e20b 0x1ef2dd 0x157e6b0 0x72d4fc0 0x72c933c 0x72d4eaf 0x28e2bd 0x1d6b56 0x1d566f 0x1d5589 0x1d47e4 0x1d461e 0x1d53d9 0x1d82d2 0x28299c 0x1cf574 0x1cf76f 0x1cf905 0x1d8917 0x2580 0x19c157 0x19c747 0x19d94b 0x1aecb5 0x1afbeb 0x1a1698 0x22c1df9 0x22c1ad0 0x1ffdbf5 0x1ffd962 0x202ebb6 0x202df44 0x202de1b 0x19d17a 0x19effc 0x227d 0x21a5)
libc++abi.dylib: terminate called throwing an exception
(lldb)
By the way the my app only crashes when I have some data to insert in the calendar.
I found the answer! I was getting a date from Core Data but the formatter was wrong and the date was coming out as nil.
Related
I am trying to do Peek and Pop in my iOS 9 capable app. The view in question has a UITableView, so I have in my code:
- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location {
// check if we're not already displaying a preview controller
if ([self.presentedViewController isKindOfClass:[WebViewController class]]) {
return nil;
}
// shallow press: return the preview controller here (peek)
self.webViewController = [[[WebViewController alloc] initWithNibName:#"WebViewController" bundle:[NSBundle mainBundle]] autorelease];
return self.webViewController;
}
- (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit {
// deep press: bring up the commit view controller (pop)
self.webViewController = [[[WebViewController alloc] initWithNibName:#"WebViewController" bundle:[NSBundle mainBundle]] autorelease];
[self showViewController:self.webViewController sender:self];
}
WebViewController is the ViewController I have already set up to display the content when the row of the tableview is selected. The error I get is:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSCFConstantString stringByAppendingString:]: nil argument'
*** First throw call stack:
(0x182160f5c 0x19764bf80 0x182160ea4 0x182fb8868 0x1001307a4 0x1876cf9ac 0x1876cf720 0x187a025f8 0x187960844 0x18796cde4 0x1876a91e4 0x182117c30 0x1821159d4 0x182115e04 0x182044dc0 0x18d4e0088 0x18771ef60 0x10014ca68 0x197e6a8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
Your log it's saying exactly what is wrong with your code:
-[__NSCFConstantString stringByAppendingString:]: nil argument'
You are performing stringByAppendingString passing a value that is nil
Also, autorelease is not used anymore if you are using ARC (it's default by now)
I am attempting to use an inline PickerView in my application, and it works fine except for one thing. when I try to set the row of the picker to a specific row based on a data argument my application crashes.
UITableViewCell *associatedTypePickerCell = [self.tableView cellForRowAtIndexPath:self.datePickerIndexPath];
UIPickerView *targetedPickerView = (UIPickerView *)[associatedTypePickerCell viewWithTag:kTypePickerTag];
if (targetedPickerView != nil){
NSLog(#"type picker ! = nil");
NSDictionary *itemData = self.dataArray[self.datePickerIndexPath.row-1];
Type *type = [itemData valueForKey:kDateKey];
NSInteger row = [[self types] indexOfObject:type];
[targetedPickerView selectRow:row inComponent:0 animated:NO];
}
I am getting this error:
-[UITableViewCell selectRow:inComponent:animated:]: unrecognized selector sent to instance 0x8ecba70
2014-07-22 23:47:23.384 MyGIJournal[16636:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell selectRow:inComponent:animated:]: unrecognized selector sent to instance 0x8ecba70'
does anyone know why this is crashing? it seems like casting like this to a UIPickerView isn't working, which doesn't make much sense cause this is the exact same way I do it for the UIDatePicker and it worked for that... Any help or advice would be greatly appreciated, Thanks!
I'm experiencing a weird crash using FBLoginView.
Scenario for crash: My view with a FBLoginView instance loads and I don't login, I go back to my previous view and load my view with the FBLoginView instance again, this causes the app to crash and I can't see what I'm doing wrong.
It's working fine if I login and repeat the same thing.
Crash log:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSCFConstantString stringByAppendingString:]: nil argument'
I found this: Very weird NSInvalidArgumentException with addSubview FBLoginView - which kind of describes the same problem, but I don't use FBLoginView in multiple views.
Code:
- (void)viewDidLoad
{
[super viewDidLoad];
if (!self.loginView) {
self.loginView = [FBLoginView new];
self.loginView.readPermissions = #[#"public_profile", #"email", #"user_friends"];
self.loginView.delegate = self;
[self.view addSubview:self.loginView];
}
}
Any suggestions?
Hey when I push another view Controller i get this in my main.m
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
I am using this to push the view controller -
-(void)showMore:(UIButton *)sender
{
MoreViewController *moreViewController = [[MoreViewController alloc] init];
[self.navigationController pushViewController:moreViewController animated:YES];
}
I am sending the message here
[moreButton addTarget:self action:#selector(showSettings:) forControlEvents:UIControlEventTouchUpInside];
Here is my Error -
2013-09-25 18:16:03.186 Time Travel[1591:60b] Application windows are expected to have a root view controller at the end of application launch
2013-09-25 18:16:05.179 Time Travel[1591:60b] -[NSConcreteValue showSettings:]: unrecognized selector sent to instance 0x14e5ea70
2013-09-25 18:16:05.181 Time Travel[1591:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteValue showSettings:]: unrecognized selector sent to instance 0x14e5ea70'
* First throw call stack:
(0x2e1e5e8b 0x384e26c7 0x2e1e97b7 0x2e1e80b7 0x2e136e98 0x309a055f 0x309a04fb 0x309a04cb 0x3098c0f3 0x3099ff13 0x3099fbdd 0x3099ac09 0x3096ff59 0x3096e747 0x2e1b0f27 0x2e1b03ef 0x2e1aebdf 0x2e119541 0x2e119323 0x32e492eb 0x309d01e5 0x4cbd5 0x389dbab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
Does it crash on the first line or the second? Add a breakpoint to each and click the continue button to check which one.
If it's the former there might be some illegal code in your alloc/init for MoreViewController.
If it's the latter, maybe there some class/delegate methods (viewDidLoad, etc) are the culprit.
What is the error message during your crash? (Sometimes clicking the resume-play-button in the debugger in Xcode can reveal a bit more after a crash.)
I didnt find a method named showSettings: in the code you posted. You are pushing your viewController in method named showMore: So I think, the code should be like this:
[moreButton addTarget:self action:#selector(showMore:) forControlEvents:UIControlEventTouchUpInside];
Please check with this.
The error message saying showSettings: method is not found
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteValue **showSettings:**]: unrecognized selector sent to instance 0x14e5ea70'
And I've notified that you are using showMore: as the name of your method
-(void)showMore:(UIButton *)sender
maybe just change showMore to showSettings, or vice versa
I have a mystery problem with UICollectionView.
I add my collection view to my tableview cell like so:
UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new];
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
UICollectionView *collection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 100) collectionViewLayout:layout];
[collection setDataSource:self];
[collection setDelegate:self];
[collection setBackgroundColor:[UIColor whiteColor]];
[collection registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:#"Cell"];
collection.tag = kTagPhotoCollectionView;
[cell.contentView addSubview:collection];
I'm implementing all the necessary delegate and data source methods and you can see I've set the datasource and delegate and have implemented them in my header.
When I go and press a UIButton which displays a UIImagePickerController and the app crashes with this error:
2013-08-13 20:17:02.578 [619:60b] *** Assertion failure in -[PUCollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes:], /SourceCache/UIKit/UIKit-2891/UICollectionView.m:1397
2013-08-13 20:17:35.502 Sparky[619:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView dataSource is not set'
*** First throw call stack:
(0x30a02ed3 0x3aa2b6c7 0x30a02da5 0x3138c72f 0x3305f647 0x32f4adf9 0x32f47139 0x32eea543 0x32b72feb 0x32b6e817 0x32b6e6a9 0x32b6e0bd 0x32b6decf 0x32b67bfd 0x309cdf71 0x309cb8ff 0x309cbc4b 0x30936541 0x30936323 0x353ca343 0x32f4f8a5 0x5f835 0x3af40ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
I have set the datasource, so I have no idea why this would occur.
I faced with the similar problem, but my app crashed after I programmatically pop my UICollectionViewController. In some reason (I think it's just a bug in SDK) self.collectionView was alive after its' controller destroy, thus causing this failure:
*** Assertion failure in -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes:], /SourceCache/UIKit/UIKit-2935.137/UICollectionView.m:1305
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView dataSource is not set'
The solution is just override -dealloc in UICollectionViewController and release self.collectionView manually. ARC code:
- (void)dealloc {
self.collectionView = nil;
}
Hope this will save time for somebody.