I'm debugging an iOS app (not an iOS developer) to try and solve a bug for a client as our iOS dev is away so apologies as this is probably obvious. The app is crashing with the following error message:
2019-06-03 16:34:05.292250+0100 SBD POP[75510:2099884] -[ComponentTableView tableView:heightForFooterInSection:]: unrecognized selector sent to instance 0x7f901d929200
2019-06-03 16:34:05.298376+0100 SBD POP[75510:2099884] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ComponentTableView tableView:heightForFooterInSection:]: unrecognized selector sent to instance 0x7f901d929200'
*** First throw call stack:
(
0 CoreFoundation 0x00000001126da6fb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x00000001116fdac5 objc_exception_throw + 48
2 CoreFoundation 0x00000001126f8ab4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 UIKitCore 0x000000011c8a0c3d -[UIResponder doesNotRecognizeSelector:] + 287
4 CoreFoundation 0x00000001126df1a1 ___forwarding___ + 769
5 CoreFoundation 0x00000001126e1238 _CF_forwarding_prep_0 + 120
6 SBD POP 0x000000010d1852b6 -[ComponentTableView tableView:heightForFooterInSection:] + 230
7 UIKitCore 0x000000011cab6106 -[UITableView _classicHeightForFooterInSection:] + 167
8 UIKitCore 0x000000011cabb02c -[UITableView _heightForFooterInSection:] + 34
9 UIKitCore 0x000000011cacabc4 -[UISectionRowData heightForFooterInSection:canGuess:] + 91
10 UIKitCore 0x000000011cad2277 -[UITableViewRowData rectForFooterInSection:heightCanBeGuessed:] + 653
11 UIKitCore 0x000000011ca890d7 -[UITableView _rectForFooterInSection:usingPresentationValues:] + 166
12 UIKitCore 0x000000011cab169e -[UITableView _hasHeaderFooterBelowRowAtIndexPath:] + 175
13 UIKitCore 0x000000011ca90c2f -[UITableView _shouldDrawSeparatorAtBottomOfSection:] + 126
14 UIKitCore 0x000000011caacf3d -[UITableView _setupCell:forEditing:atIndexPath:canEdit:editingStyle:shouldIndentWhileEditing:showsReorderControl:accessoryType:animated:updateSeparators:] + 1264
15 UIKitCore 0x000000011caad23f -[UITableView _setupCell:forEditing:atIndexPath:animated:updateSeparators:] + 665
16 UIKitCore 0x000000011ca9b3cb __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 2569
17 UIKitCore 0x000000011cd34a19 +[UIView(Animation) performWithoutAnimation:] + 90
18 UIKitCore 0x000000011ca9a8db -[UITableView _configureCellForDisplay:forIndexPath:] + 237
19 UIKitCore 0x000000011caad6bf -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 911
20 UIKitCore 0x000000011caadb65 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 73
21 UIKitCore 0x000000011ca75d20 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2870
22 UIKitCore 0x000000011ca95e37 -[UITableView layoutSubviews] + 165
23 UIKitCore 0x000000011cd429c1 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1417
24 QuartzCore 0x000000010e051eae -[CALayer layoutSublayers] + 173
25 QuartzCore 0x000000010e056b88 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 396
26 UIKitCore 0x000000011cd2d985 -[UIView(Hierarchy) layoutBelowIfNeeded] + 646
27 UIKitCore 0x000000011c1d5ec8 -[UINavigationController _layoutViewController:] + 1756
28 UIKitCore 0x000000011c1cfad8 -[UINavigationController _layoutTopViewController] + 223
29 UIKitCore 0x000000011c1cde01 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 732
30 UIKitCore 0x000000011ccfa4b6 -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] + 418
31 UIKitCore 0x000000011ccfa779 -[UINavigationTransitionView _cleanupTransition] + 608
32 UIKitCore 0x000000011cd098ff -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 343
33 UIKitCore 0x000000011cd0516d +[UIViewAnimationState popAnimationState] + 319
34 UIKitCore 0x000000011ccfa229 -[UINavigationTransitionView transition:fromView:toView:] + 2363
35 UIKitCore 0x000000011c1d6efb -[UINavigationController _startTransition:fromViewController:toViewController:] + 3222
36 UIKitCore 0x000000011c1d73b5 -[UINavigationController _startDeferredTransitionIfNeeded:] + 896
37 UIKitCore 0x000000011c1d86a7 -[UINavigationController __viewWillLayoutSubviews] + 150
38 UIKitCore 0x000000011c1b938d -[UILayoutContainerView layoutSubviews] + 217
39 UIKitCore 0x000000011cd429c1 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1417
40 QuartzCore 0x000000010e051eae -[CALayer layoutSublayers] + 173
41 QuartzCore 0x000000010e056b88 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 396
42 QuartzCore 0x000000010e062ee4 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 72
43 QuartzCore 0x000000010dfd23aa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 328
44 QuartzCore 0x000000010e009584 _ZN2CA11Transaction6commitEv + 608
45 UIKitCore 0x000000011c86ed8a _UIApplicationFlushRunLoopCATransactionIfTooLate + 150
46 UIKitCore 0x000000011c961f5f __handleEventQueueInternal + 6845
47 CoreFoundation 0x0000000112641be1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
48 CoreFoundation 0x0000000112641463 __CFRunLoopDoSources0 + 243
49 CoreFoundation 0x000000011263bb1f __CFRunLoopRun + 1231
50 CoreFoundation 0x000000011263b302 CFRunLoopRunSpecific + 626
51 GraphicsServices 0x0000000117f812fe GSEventRunModal + 65
52 UIKitCore 0x000000011c874ba2 UIApplicationMain + 140
53 SBD POP 0x000000010d16fc00 main + 112
54 libdyld.dylib 0x000000011606f541 start + 1
55 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I've tracked the problem down to this function (print statements are mine):
#import "ComponentTableView.h"
#import "Component.h"
#import "CoreData.h"
#import "UIPositioning.h"
#import "UIView+utils.h"
#import "UIColor+appColors.h"
#import "TotalRowView.h"
#import "NSUserDefaults+Preferences.h"
#implementation ComponentTableView
//Other code/functions here
#pragma mark - UITableViewDelegate
//Other code/functions here
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
printf("Section: %f\n", section);
switch (section) {
case 0:
{
printf("Section - Case 0\n");
if([self showSectionFooters])
{
printf("Section - Case 0 - If Statement\n");
return [super tableView:tableView heightForFooterInSection:section];
}
break;
}
case 1:
{
printf("Section - Case 1\n");
return [super tableView:tableView heightForFooterInSection:section];
break;
}
default:
{
printf("Section - Default\n");
break;
}
}
return 0;
}
ComponentTableView.h
#import "DisplayItemTableView.h"
#class ComponentTableView;
#protocol ComponentTableViewDelegate <NSObject>
- (void)onComponentTableControllerDidChangeContent:(ComponentTableView*) componentTableView;
#optional
- (void)onComponentTableViewEdit:(ComponentTableView*) componentTableView;
- (void)onDisplayItemTableVerifiedComponentsChanged:(ComponentTableView*) componentTableView;
#end
#interface ComponentTableView : DisplayItemTableView <DisplayItemViewDelegate>
#property BOOL includePreviewImage;
#property BOOL standComponentIsMandatory;
-(BOOL) outOfStock;
#property (strong, nonatomic) NSCountedSet<NSString*>* verifiedComponentSet;
#property (weak, nonatomic) id<ComponentTableViewDelegate> parentDelegate;
#property (strong, nonatomic) Component* stand;
-(CGFloat) contentHeight;
-(CGFloat) retailCost;
-(CGFloat) merchCost;
- (id) initWithComponentUIDSet:(NSCountedSet<NSString*> *) componentUIDSet;
+(CGFloat) contentHeight:(NSCountedSet*) uidset;
#end
DisplayItemTableView.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import "DisplayItemView.h"
#import "TotalRowView.h"
#class DisplayItemTableView;
#interface DisplayItemTableView : UITableView<UITableViewDelegate, UITableViewDataSource, NSFetchedResultsControllerDelegate>
#property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
#property (strong, nonatomic) RetailTotalView *retailTotalView;
#property (strong, nonatomic) MerchandisingTotalView *merchTotalView;
-(id) initWithHeight:(CGFloat) height;
-(id) initWithTopAndHeight:(CGFloat) top :(CGFloat) height;
+(CGFloat) displayItemHeight:(NSString*) name :(NSString*) sku :(BOOL) includePreviewImage;
+(UIColor*) separatorColor;
#end
Testing with the console prints turned on lets me know that it's the return statements:
return [super tableView:tableView heightForFooterInSection:section];
Which are causing the unregonised selector error - if I comment out case0/case1 and just leave the default the app functions but the table being generated isn't formatted correctly. Anyone have any ideas?
UITableView does not implement conformance to UITableViewDelegate, so it doesn't guarantee that it provides the method -tableView:heightForFooterInSection:. However, when ComponentTableView calls super, it's attempting to find exactly that method. You can't send a message to super when the superclass doesn't implement it.
Instead of sending to super to get a "default" value, think about what you actually want the value to be. If it's "no footer," simply return 0 from ComponentTableView's implementation. If it's "however tall Auto Layout says," return UITableViewAutomaticDimension.
One last note: many iOS apps make a point of separating the table view from its delegate and data source. You may want to consider using a view controller or other object as the delegate, instead of subclassing UITableView to implement those protocols.
Related
I press on CONTROL and drag the UIImageVIew and UILabel which is in AppView.xib to my code file named "AppVIew.h". Before I connect the two UI widgets it ran ok ,I want to know the reasons leading to the crash.Very thanks for your answers.
#property
The code as following:
#import <UIKit/UIKit.h>
#interface AppView : UIView
#property (weak, nonatomic) IBOutlet UIImageView *icon;
#property (weak, nonatomic) IBOutlet UILabel *name;
+ (id)AppViewWithIcon:(NSString *)icon Name:(NSString *)name;
#end
#import "AppView.h"
#implementation AppView
+ (id)AppViewWithIcon:(NSString *)icon Name:(NSString *)name{
AppView *view = [[NSBundle mainBundle] loadNibNamed:#"AppView" owner:nil options:nil][0];
NSLog(#"%#",view);
return view;
}
the errors as following:
1.Thread 1:EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP,subcode=0X0)
2.2016-03-27 18:53:36.804 05-九宫格[4302:283744] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSObject 0x7fca52c1a1c0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key icon.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000101630d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001010a4deb objc_exception_throw + 48
2 CoreFoundation 0x00000001016309c9 -[NSException raise] + 9
3 Foundation 0x0000000100c6f19b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4 UIKit 0x0000000101db07fb -[UIRuntimeOutletConnection connect] + 109
5 CoreFoundation 0x000000010156a890 -[NSArray makeObjectsPerformSelector:] + 224
6 UIKit 0x0000000101daf1de -[UINib instantiateWithOwner:options:] + 1864
7 UIKit 0x0000000101db1415 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 223
8 05-九宫格 0x0000000100ba1490 +[AppView AppViewWithIcon:Name:] + 160
9 05-九宫格 0x0000000100ba0cae -[ViewController viewDidLoad] + 206
10 UIKit 0x0000000101b81984 -[UIViewController loadViewIfRequired] + 1198
11 UIKit 0x0000000101b81cd3 -[UIViewController view] + 27
12 UIKit 0x0000000101a57fb4 -[UIWindow addRootViewControllerViewIfPossible] + 61
13 UIKit 0x0000000101a5869d -[UIWindow _setHidden:forced:] + 282
14 UIKit 0x0000000101a6a180 -[UIWindow makeKeyAndVisible] + 42
15 UIKit 0x00000001019deed9 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
16 UIKit 0x00000001019e5568 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1769
17 UIKit 0x00000001019e2714 -[UIApplication workspaceDidEndTransaction:] + 188
18 FrontBoardServices 0x000000010444f8c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
19 FrontBoardServices 0x000000010444f741 -[FBSSerialQueue _performNext] + 178
20 FrontBoardServices 0x000000010444faca -[FBSSerialQueue _performNextFromRunLoopSource] + 45
21 CoreFoundation 0x0000000101556301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22 CoreFoundation 0x000000010154c22c __CFRunLoopDoSources0 + 556
23 CoreFoundation 0x000000010154b6e3 __CFRunLoopRun + 867
24 CoreFoundation 0x000000010154b0f8 CFRunLoopRunSpecific + 488
25 UIKit 0x00000001019e1f21 -[UIApplication _run] + 402
26 UIKit 0x00000001019e6f09 UIApplicationMain + 171
27 05-九宫格 0x0000000100ba195f main + 111
28 libdyld.dylib 0x0000000103e0a92d start + 1
29 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Check if their are any previous outlets that have been deleted from within the storyboard, by either checking the view controller inspector and referencing outlets for any outlets that may contradict the ones you have made as well as the UIView/UILabel.
I am working on an iOS app, but for some reason all of a sudden my login page is not working anymore. All of the UIElements seem to be working fine except for the UITextField I use for the username (Password textField is working fine).
The login screen is very basic, it has a one viewcontroller and the username textfield has one outlet in that viewcontroller.
I don't do anything with the textfield when it focuses.
It happens on iOS8 on the physical iPad 2, and on the iPhone 4s emulator.
What I have tried to do:
Re-install the app
Re-ad the textField
Re-connect the Outlet
Revert my storyboard to a working version
I found some other answers, but none of them seem to have a conclusive answer.
Exception:
2015-03-24 11:13:53.695 App[43084:866627] -[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x7ae5f920
2015-03-24 11:13:53.726 App[43084:866627] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x7ae5f920'
*** First throw call stack:
(
0 CoreFoundation 0x00def466 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x006d7a97 objc_exception_throw + 44
2 CoreFoundation 0x00df72c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x00d3fbc7 ___forwarding___ + 1047
4 CoreFoundation 0x00d3f78e _CF_forwarding_prep_0 + 14
5 CoreFoundation 0x00cc531c CFArrayGetValueAtIndex + 188
6 CoreFoundation 0x00d601ed CFStringTokenizerCreate + 749
7 UIKit 0x01c377ce __91-[_UITextInputControllerTokenizer _getClosestTokenRangeForPosition:granularity:downstream:]_block_invoke44 + 264
8 UIFoundation 0x0439e9d3 -[NSTextStorage coordinateReading:] + 51
9 UIKit 0x01c37459 -[_UITextInputControllerTokenizer _getClosestTokenRangeForPosition:granularity:downstream:] + 276
10 UIKit 0x018ba567 -[UITextInputStringTokenizer positionFromPosition:toBoundary:inDirection:] + 93
11 UIKit 0x018bad9d -[TIDocumentState(UITextInputAdditions) _contextBeforePosition:inDocument:] + 81
12 UIKit 0x018baef3 -[TIDocumentState(UITextInputAdditions) initWithDocument:] + 125
13 UIKit 0x018ba95f +[TIDocumentState(UITextInputAdditions) documentStateOfDocument:] + 63
14 UIKit 0x015fad7b -[UIKeyboardImpl syncDocumentStateToInputDelegateWithExecutionContext:] + 298
15 UIKit 0x015fb787 -[UIKeyboardImpl updateForChangedSelectionWithExecutionContext:] + 326
16 UIKit 0x015f57b6 __36-[UIKeyboardImpl setDelegate:force:]_block_invoke + 43
17 UIKit 0x01c384b2 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 404
18 UIKit 0x01c38b6f -[UIKeyboardTaskQueue addTask:] + 144
19 UIKit 0x015f5783 -[UIKeyboardImpl setDelegate:force:] + 2450
20 UIKit 0x015f4dec -[UIKeyboardImpl setDelegate:] + 60
21 UIKit 0x01928fe5 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1096
22 UIKit 0x01570687 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 316
23 UIKit 0x0156f6ec -[UIResponder becomeFirstResponder] + 562
24 UIKit 0x01435ba0 -[UIView(Hierarchy) becomeFirstResponder] + 114
25 UIKit 0x01c04607 -[UITextField becomeFirstResponder] + 51
26 UIKit 0x018051bf -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 200
27 UIKit 0x018077e6 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 2762
28 UIKit 0x017fb057 _UIGestureRecognizerSendActions + 327
29 UIKit 0x017f98d4 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 561
30 UIKit 0x017fb91d -[UIGestureRecognizer _delayedUpdateGesture] + 60
31 UIKit 0x017ff29a ___UIGestureRecognizerUpdate_block_invoke661 + 57
32 UIKit 0x017ff15d _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317
33 UIKit 0x017f3066 _UIGestureRecognizerUpdate + 3720
34 UIKit 0x0140ac5b -[UIWindow _sendGesturesForEvent:] + 1356
35 UIKit 0x0140babf -[UIWindow sendEvent:] + 769
36 UIKit 0x013d0bb1 -[UIApplication sendEvent:] + 242
37 UIKit 0x013e0bf6 _UIApplicationHandleEventFromQueueEvent + 21066
38 UIKit 0x013b4bc7 _UIApplicationHandleEventQueue + 2300
39 CoreFoundation 0x00d1298f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
40 CoreFoundation 0x00d0849d __CFRunLoopDoSources0 + 253
41 CoreFoundation 0x00d079f8 __CFRunLoopRun + 952
42 CoreFoundation 0x00d0737b CFRunLoopRunSpecific + 443
43 CoreFoundation 0x00d071ab CFRunLoopRunInMode + 123
44 GraphicsServices 0x04e182c1 GSEventRunModal + 192
45 GraphicsServices 0x04e180fe GSEventRun + 104
46 UIKit 0x013b89b6 UIApplicationMain + 1526
47 App 0x0005ffbd main + 141
48 libdyld.dylib 0x0296dac9 start + 1
49 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Viewcontroller:
#import "LoginViewController.h"
#implementation LoginViewController
UserManager *usermanager;
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (IBAction)cancelLogin:(id)sender {
[self dismissViewControllerAnimated:true completion:nil];
}
- (IBAction)login:(id)sender {
[loginIndicator startAnimating];
LoginHandler *loginhandler = [[LoginHandler alloc]initWithUsername:usernameField.text
password:passwordField.text
beta:betaSwitch.isOn
view:self];
[loginhandler loginUser];
}
-(void)resetFields{
usernameField.text = #"";
passwordField.text = #"";
[loginIndicator stopAnimating];
}
#end
Viewcontroller.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "LoginHandler.h"
#interface LoginViewController : UIViewController{
__weak IBOutlet UITextField *usernameField;
__weak IBOutlet UITextField *passwordField;
__weak IBOutlet UIActivityIndicatorView *loginIndicator;
__weak IBOutlet UISwitch *betaSwitch;
__weak IBOutlet UINavigationBar *navigationBar;
}
-(void)resetFields;
#end
An exception breakpoint gives this line:
2015-03-24 11:43:41.338 App[323:15867] -[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x15653690
Can anyone else help me?
Thanks
I seem to have found an answer, it had something to do with my constraints for some reason. I cleared the constraints and re-added them and somehow it is working again.
I am using a navigation controller with the structure in the image below. When the user is on SigupViewController and is successful, I call
[self.navigationController popToRootViewControllerAnimated:YES];
This leads to the error below. If I remove this line, I don’t get an error. What is weird is that I have this same line in the LoginViewController (the one before it) and when it gets called, it executes as expected without error. Any advice on what I should fix?
Error:
2014-03-05 06:39:49.240 Walk With Me[2035:70b] worked
2014-03-05 06:39:49.245 Walk With Me[2035:70b] -[SigupViewController signup:]: unrecognized selector sent to instance 0xa5599b0
2014-03-05 06:39:49.249 Walk With Me[2035:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SigupViewController signup:]: unrecognized selector sent to instance 0xa5599b0'
*** First throw call stack:
(
0 CoreFoundation 0x038635e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x035e68b6 objc_exception_throw + 44
2 CoreFoundation 0x03900903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0385390b ___forwarding___ + 1019
4 CoreFoundation 0x038534ee _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x035f881f -[NSObject performSelector:withObject:] + 70
6 UIKit 0x023560c2 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x0235604e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x0244e0c1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x0244e484 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x02a32853 -[UITextField _resignFirstResponder] + 300
11 UIKit 0x024ae08e -[UIResponder _finishResignFirstResponder] + 181
12 UIKit 0x024ae1b6 -[UIResponder resignFirstResponder] + 288
13 UIKit 0x02a325f4 -[UITextField resignFirstResponder] + 118
14 UIKit 0x023af044 -[UIView(Hierarchy) _removeFirstResponderFromSubtree] + 205
15 UIKit 0x023af366 __UIViewWillBeRemovedFromSuperview + 71
16 UIKit 0x023af238 -[UIView(Hierarchy) removeFromSuperview] + 70
17 UIKit 0x0267a6a3 -[UINavigationTransitionView _cleanupTransition] + 103
18 UIKit 0x0267a93a -[UINavigationTransitionView _navigationTransitionDidStop] + 55
19 UIKit 0x023a0c6c -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 267
20 UIKit 0x0239f455 +[UIViewAnimationState popAnimationState] + 334
21 UIKit 0x023b3cf6 +[UIView(Animation) commitAnimations] + 36
22 UIKit 0x0267a3f9 -[UINavigationTransitionView transition:fromView:toView:] + 2795
23 UIKit 0x02679906 -[UINavigationTransitionView transition:toView:] + 55
24 UIKit 0x0248ed47 -[UINavigationController _startTransition:fromViewController:toViewController:] + 3186
25 UIKit 0x0248f09c -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
26 UIKit 0x0248fcb9 -[UINavigationController __viewWillLayoutSubviews] + 57
27 UIKit 0x025c9181 -[UILayoutContainerView layoutSubviews] + 213
28 UIKit 0x023bf267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
29 libobjc.A.dylib 0x035f881f -[NSObject performSelector:withObject:] + 70
30 QuartzCore 0x0222e2ea -[CALayer layoutSublayers] + 148
31 QuartzCore 0x022220d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
32 QuartzCore 0x02221f40 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
33 QuartzCore 0x02189ae6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
34 QuartzCore 0x0218ae71 _ZN2CA11Transaction6commitEv + 393
35 QuartzCore 0x0218b544 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
36 CoreFoundation 0x0382b4ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
37 CoreFoundation 0x0382b41f __CFRunLoopDoObservers + 399
38 CoreFoundation 0x03809344 __CFRunLoopRun + 1076
39 CoreFoundation 0x03808ac3 CFRunLoopRunSpecific + 467
40 CoreFoundation 0x038088db CFRunLoopRunInMode + 123
41 GraphicsServices 0x045be9e2 GSEventRunModal + 192
42 GraphicsServices 0x045be809 GSEventRun + 104
43 UIKit 0x02354d3b UIApplicationMain + 1225
44 Walk With Me 0x00005bbd main + 141
45 libdyld.dylib 0x03da470d start + 1
46 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Code:
PFUser *user = [PFUser user];
user.username = username;
user.password = password;
user.email = email;
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
NSLog(#"worked");
[self.navigationController popToRootViewControllerAnimated:YES];
}
else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Sorry!" message:[error.userInfo objectForKey:#"error"] delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}
}];
SigUpViewController.h:
#import <UIKit/UIKit.h>
#interface SigupViewController : UIViewController
#property (weak, nonatomic) IBOutlet UITextField *usernameField;
#property (weak, nonatomic) IBOutlet UITextField *passwordField;
#property (weak, nonatomic) IBOutlet UITextField *emailField;
- (IBAction)signingU:(id)sender;
#end
You are calling
[SigupViewController signup:]:
But there is no method with that signature in the SigupViewController class. I assume you've linked this up in IB so add:
- (IBAction) signup:(id) sender;
In your SigupViewController.h
Alternatively remove the call to this method if it's a mistake.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
This is what I get when I press the done button on the keyboard of a UITextField: (code to follow)
2013-10-14 23:22:55.170 What to where?[21627:a0b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(
0 CoreFoundation 0x0008e5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0178e8b6 objc_exception_throw + 44
2 CoreFoundation 0x00042a32 -[__NSArrayI objectAtIndex:] + 210
3 What to where? 0x00002670 -[ViewController getWeatherForecast] + 352
4 What to where? 0x00002430 -[ViewController textFieldDidEndEditing:] + 288
5 libobjc.A.dylib 0x017a081f -[NSObject performSelector:withObject:] + 70
6 UIKit 0x00502c8c -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x00502c18 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x005fa6d9 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x005faa9c -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x00bddaf3 -[UITextField _resignFirstResponder] + 300
11 UIKit 0x0065a71e -[UIResponder _finishResignFirstResponder] + 181
12 UIKit 0x0065a82f -[UIResponder resignFirstResponder] + 265
13 UIKit 0x00bdd894 -[UITextField resignFirstResponder] + 118
14 What to where? 0x000024d9 -[ViewController textFieldShouldReturn:] + 137
15 UIKit 0x00be68bf -[UITextField keyboardInput:shouldInsertText:isMarkedText:] + 357
16 UIKit 0x006d5a43 -[UIKeyboardImpl callShouldInsertText:] + 271
17 UIKit 0x006dfd20 -[UIKeyboardImpl addWordTerminator:afterSpace:elapsedTime:executionContext:] + 63
18 UIKit 0x006df81a -[UIKeyboardImpl completeAcceptCandidateBeforeAddingInput:executionContext:] + 1668
19 UIKit 0x006df0f6 __60-[UIKeyboardImpl addInputString:withFlags:executionContext:]_block_invoke + 53
20 UIKit 0x00c0dc6e -[UIKeyboardTaskExecutionContext returnExecutionToParent] + 254
21 UIKit 0x006e299b -[UIKeyboardImpl acceptCurrentCandidateIfSelectedWithExecutionContext:] + 250
22 UIKit 0x006df0b9 -[UIKeyboardImpl addInputString:withFlags:executionContext:] + 451
23 UIKit 0x006ddf7f -[UIKeyboardImpl handleStringInput:withFlags:executionContext:] + 248
24 UIKit 0x006ec16f -[UIKeyboardImpl handleKeyWithString:forKeyEvent:executionContext:] + 633
25 UIKit 0x006ebcb6 -[UIKeyboardImpl handleKeyEvent:executionContext:] + 1808
26 UIKit 0x006eb50f __33-[UIKeyboardImpl handleKeyEvent:]_block_invoke + 51
27 UIKit 0x006eb31c -[UIKeyboardImpl _handleKeyEvent:executionContext:] + 243
28 UIKit 0x008642e9 -[UIKeyboardLayoutStar completeRetestForTouchUp:timestamp:interval:executionContext:] + 4078
29 UIKit 0x00862def -[UIKeyboardLayoutStar touchUp:executionContext:] + 1545
30 UIKit 0x006f9398 __28-[UIKeyboardLayout touchUp:]_block_invoke + 269
31 UIKit 0x00c0e1b8 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 402
32 UIKit 0x00c0e85f -[UIKeyboardTaskQueue addTask:] + 144
33 UIKit 0x006f9283 -[UIKeyboardLayout touchUp:] + 263
34 UIKit 0x006f9db9 -[UIKeyboardLayout touchesEnded:withEvent:] + 362
35 UIKit 0x005400cd -[UIWindow _sendTouchesForEvent:] + 852
36 UIKit 0x00540d34 -[UIWindow sendEvent:] + 1232
37 UIKit 0x00514a36 -[UIApplication sendEvent:] + 242
38 UIKit 0x004fed9f _UIApplicationHandleEventQueue + 11421
39 CoreFoundation 0x000178af __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
40 CoreFoundation 0x0001723b __CFRunLoopDoSources0 + 235
41 CoreFoundation 0x0003430e __CFRunLoopRun + 910
42 CoreFoundation 0x00033b33 CFRunLoopRunSpecific + 467
43 CoreFoundation 0x0003394b CFRunLoopRunInMode + 123
44 GraphicsServices 0x036859d7 GSEventRunModal + 192
45 GraphicsServices 0x036857fe GSEventRun + 104
46 UIKit 0x0050194b UIApplicationMain + 1225
47 What to where? 0x00002d3d main + 141
48 libdyld.dylib 0x01fbf725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
The code in the .h :
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#interface ViewController : UIViewController <UITextFieldDelegate> {
NSString *location;
NSString *time;
}
#property (strong, nonatomic) IBOutlet UITextField *destinationTF;
#property (strong, nonatomic) IBOutlet UITextField *timeTF;
- (IBAction)textFieldDidEndEditing:(id)sender;
#end
And the .m:
#synthesize destinationTF, timeTF;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)textFieldDidEndEditing:(id)sender {
if (sender == destinationTF ) {
location = destinationTF.text;
} else if (sender == timeTF) {
time = timeTF.text;
}
[self getWeatherForecast];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[destinationTF resignFirstResponder];
[timeTF resignFirstResponder];
return YES;
}
0x00042a32 -[__NSArrayI objectAtIndex:] + 210
I don't have the source code to your getWeatherForcast method, but I would guess that that array is empty. Before you execute any code on the array try:
if ([someArray lastObject]) {
..Do something
} else {
do something if the test fails
}
This is safe and will not crash because the array is out of bounds. (It just returns nil)
I think iOS 7 added firstObject as well.
The crash is due to an index out of bounds error and it is occurring in your getWeatherForecast method. You may be attempting to get an object out of an empty array...
Another problem that is causing my build to succeed, then terminate. As follows:
Error:
2013-09-30 20:21:23.708 The Solver[2566:a0b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIView 0x89bfd40> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key welcomeBeta.'
*** First throw call stack:
(
0 CoreFoundation 0x023615e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bf8b6 objc_exception_throw + 44
2 CoreFoundation 0x023f16a1 -[NSException raise] + 17
3 Foundation 0x00f73c2e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x00edff3b _NSSetUsingKeyValueSetter + 88
5 Foundation 0x00edf493 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6 UIKit 0x0008f97b -[UIView(CALayerDelegate) setValue:forKey:] + 168
7 Foundation 0x00f4194a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
8 UIKit 0x002c6cd5 -[UIRuntimeOutletConnection connect] + 106
9 libobjc.A.dylib 0x014d17d2 -[NSObject performSelector:] + 62
10 CoreFoundation 0x0235cb6a -[NSArray makeObjectsPerformSelector:] + 314
11 UIKit 0x002c582e -[UINib instantiateWithOwner:options:] + 1417
12 UIKit 0x00137c95 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
13 UIKit 0x0013843d -[UIViewController loadView] + 302
14 UIKit 0x0013873e -[UIViewController loadViewIfRequired] + 78
15 UIKit 0x00138c44 -[UIViewController view] + 35
16 UIKit 0x000615ad -[UIWindow addRootViewControllerViewIfPossible] + 66
17 UIKit 0x00061947 -[UIWindow _setHidden:forced:] + 312
18 UIKit 0x00061bdd -[UIWindow _orderFrontWithoutMakingKey] + 49
19 UIKit 0x0006c44a -[UIWindow makeKeyAndVisible] + 65
20 UIKit 0x0001f8e0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
21 UIKit 0x00023fb8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
22 UIKit 0x0003842c -[UIApplication handleEvent:withNewEvent:] + 3447
23 UIKit 0x00038999 -[UIApplication sendEvent:] + 85
24 UIKit 0x00025c35 _UIApplicationHandleEvent + 736
25 GraphicsServices 0x022bf2eb _PurpleEventCallback + 776
26 GraphicsServices 0x022bedf6 PurpleEventCallback + 46
27 CoreFoundation 0x022dcdd5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
28 CoreFoundation 0x022dcb0b __CFRunLoopDoSource1 + 523
29 CoreFoundation 0x023077ec __CFRunLoopRun + 2156
30 CoreFoundation 0x02306b33 CFRunLoopRunSpecific + 467
31 CoreFoundation 0x0230694b CFRunLoopRunInMode + 123
32 UIKit 0x000236ed -[UIApplication _run] + 840
33 UIKit 0x0002594b UIApplicationMain + 1225
34 The Solver 0x000033dd main + 141
35 libdyld.dylib 0x059a5725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Code for UIControllerView with welcomeBeta (Button)
WelcomeUI.h:
#import <UIKit/UIKit.h>
#interface WelcomeUI : UIViewController
#property (weak, nonatomic) IBOutlet UIButton *welcomeStart;
#property (weak, nonatomic) IBOutlet UIButton *welcomeBeta;
#end
WelcomeUI.m:
#import "WelcomeUI.h"
#interface WelcomeUI ()
#end
#implementation WelcomeUI
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
Please let me know where I'm going wrong. Also explain in detail as I'm new to objective-c and Xcode.