Getting error for passed in UserId in tab controller? - ios

I am not sure why I keep getting this error, I do pass the userId from the profile view controller on a button click with a push:
TotalTabController *userTabView = [[UIStoryboard storyboardWithName:#"Main" bundle:nil] instantiateViewControllerWithIdentifier:#"userTabView"];
userTabView.userProfileId = userId;
NSLog(#"the user tota tab is %#", userId);
userTabView.userProfileName = profileName;
[self.navigationController pushViewController:userTabView animated:NO];
The NSLog prints out the correct userID, and then I have it added to the tab controller in the .h file like so:
#interface TotalTabController : UITabBarController {
NSString *userProfileId, *userProfileName;
}
#property (nonatomic, retain) NSString *userProfileId;
#property (nonatomic, retain) NSString *userProfileName;
And in the .m file like so:
#synthesize userProfileId, userProfileName;
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(#"the tab loaded and is %#", userProfileId);
}
but the NSLog prints out null in the .m file...
Then I call it in one of the tab views .m file like so:
userProfileId = [(TotalTabController*)self.tabBarController userProfileId];
And then get this error:
The error is:
2014-05-17 11:49:04.667 Example[1108:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
0 CoreFoundation 0x01e291e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01ba88e5 objc_exception_throw + 44
2 CoreFoundation 0x01def376 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 390
3 CoreFoundation 0x01e1cc29 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 73
4 Example 0x00012233 -[CreatedCollectionViewController getCreatedNames] + 419
5 Example 0x0001202b -[CreatedCollectionViewController viewDidLoad] + 123
6 UIKit 0x0098733d -[UIViewController loadViewIfRequired] + 696
7 UIKit 0x009875d9 -[UIViewController view] + 35
8 UIKit 0x009bf11f -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 407
9 UIKit 0x009be943 -[UITabBarController transitionFromViewController:toViewController:] + 63
10 UIKit 0x009babed -[UITabBarController _setSelectedViewController:] + 281
11 UIKit 0x009baacc -[UITabBarController setSelectedViewController:] + 180
12 UIKit 0x009b7e30 __87-[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:]_block_invoke + 43
13 UIKit 0x008ce81f +[UIView(Animation) performWithoutAnimation:] + 82
14 UIKit 0x009b7cd5 -[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 247
15 UIKit 0x009b8ae9 -[UITabBarController viewWillAppear:] + 148
16 UIKit 0x0098b04b -[UIViewController _setViewAppearState:isAnimating:] + 448
17 UIKit 0x0098b548 -[UIViewController __viewWillAppear:] + 114
18 UIKit 0x0099c105 -[UIViewController(UIContainerViewControllerProtectedMethods) beginAppearanceTransition:animated:] + 199
19 UIKit 0x009a1a5e -[UINavigationController _startCustomTransition:] + 1062
20 UIKit 0x009ae8f7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688
21 UIKit 0x009af4e9 -[UINavigationController __viewWillLayoutSubviews] + 57
22 UIKit 0x00af00d1 -[UILayoutContainerView layoutSubviews] + 213
23 UIKit 0x008d7964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
24 libobjc.A.dylib 0x01bba82b -[NSObject performSelector:withObject:] + 70
25 QuartzCore 0x0455045a -[CALayer layoutSublayers] + 148
26 QuartzCore 0x04544244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
27 QuartzCore 0x045440b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
28 QuartzCore 0x044aa7fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
29 QuartzCore 0x044abb85 _ZN2CA11Transaction6commitEv + 393
30 QuartzCore 0x045695b0 +[CATransaction flush] + 52
31 UIKit 0x008669bb _UIApplicationHandleEventQueue + 13095
32 CoreFoundation 0x01db277f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
33 CoreFoundation 0x01db210b __CFRunLoopDoSources0 + 235
34 CoreFoundation 0x01dcf1ae __CFRunLoopRun + 910
35 CoreFoundation 0x01dce9d3 CFRunLoopRunSpecific + 467
36 CoreFoundation 0x01dce7eb CFRunLoopRunInMode + 123
37 GraphicsServices 0x03be85ee GSEventRunModal + 192
38 GraphicsServices 0x03be842b GSEventRun + 104
39 UIKit 0x00868f9b UIApplicationMain + 1225
40 Stand 0x00013a3d main + 141
41 libdyld.dylib 0x02575701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
The ultimate goal is to pass the userID from the profile.m file to the tab controller and allow each tab to have access to the userID, not sure what I am doing wrong, if someone can notice the error or let me know how I can have it so that it is not null and accessible?
Update
I am thinking maybe it has to do with not being able to push a tabcontroller according to apple's guidelines, could that be the case? If so how do I go around it, or what options do I have?

Hi the problem here is that you are trying to push tab bar controller in navigation controller but apple forbids it Link .So you can add the tabbar controller modally or create a custom tab bar in a view controller and push it

Related

Getting [__NSArrayM insertObject:atIndex:] tough the value is not nil

I am working on UIPageViewController and I make strong for the global instance in properties below code:
UIViewController* aController = someviewController;//(I am getting the aController value)
NSArray* viewControllers = [[NSArray alloc] initWithObjects:aController, nil];
//(I am getting the viewControllers value as well).
[self.pageController setViewControllers:viewControllers
direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
//(I am getting crash here saying [__NSArrayM insertObject:atIndex:]: object cannot be nil').
All the instances are holding the values don't know where viewControllers is becoming nil.
please let me know
0 CoreFoundation 0x0000000105471e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010626ddeb objc_exception_throw + 48
2 CoreFoundation 0x00000001053388c5 -[__NSArrayM insertObject:atIndex:] + 901
3 0x0000000103df0b5e -[MZDashBoardViewController viewDidLoad] + 1470
4 UIKit 0x00000001071fbf98 -[UIViewController loadViewIfRequired] + 1198
5 UIKit 0x00000001071fc2e7 -[UIViewController view] + 27
6 UIKit 0x00000001077d57df -[UIPageViewController _setViewControllers:withScrollInDirection:animated:completion:] + 585
7 UIKit 0x00000001077d59fb -[UIPageViewController setViewControllers:direction:animated:completion:] + 166
8 0x0000000103decba5 -[MZMainDashViewController viewDidLoad] + 2997
9 UIKit 0x00000001071fbf98 -[UIViewController loadViewIfRequired] + 1198
10 UIKit 0x0000000107240651 -[UINavigationController _layoutViewController:] + 54
11 UIKit 0x0000000107240f26 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 462
12 UIKit 0x0000000107241098 -[UINavigationController _startTransition:fromViewController:toViewController:] + 126
13 UIKit 0x00000001072422f1 -[UINavigationController _startDeferredTransitionIfNeeded:] + 890
14 UIKit 0x00000001072433af -[UINavigationController __viewWillLayoutSubviews] + 57
15 UIKit 0x00000001073e9ff7 -[UILayoutContainerView layoutSubviews] + 248
16 UIKit 0x000000010711c4a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
17 QuartzCore 0x0000000106d8359a -[CALayer layoutSublayers] + 146
18 QuartzCore 0x0000000106d77e70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
19 QuartzCore 0x0000000106d77cee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
20 QuartzCore 0x0000000106d6c475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
21 QuartzCore 0x0000000106d99c0a _ZN2CA11Transaction6commitEv + 486
22 QuartzCore 0x0000000106d9a37c _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
23 CoreFoundation 0x000000010539d367 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
24 CoreFoundation 0x000000010539d2d7 __CFRunLoopDoObservers + 391
25 CoreFoundation 0x0000000105392f2b __CFRunLoopRun + 1147
26 CoreFoundation 0x0000000105392828 CFRunLoopRunSpecific + 488
27 GraphicsServices 0x000000010988fad2 GSEventRunModal + 161
28 UIKit 0x0000000107065610 UIApplicationMain + 171
29 0x0000000103dd2d3f main + 111
30 libdyld.dylib 0x00000001086e092d start + 1
31 ??? 0x0000000000000001 0x0 + 1
Clearly you are trying to insert an object into an immutable array, not a mutable array. Somewhere inside viewDidLoad. Remember just because a variable has type NSMutableArray* doesn't mean it is.

Crash on focus UITextField

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.

How to fix error with popToRootViewController?

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.

Crash attempting to set delegate of textfield

I have a lot of textfields and what I am trying to make them do is dismiss when the return key is used. In order for this to work you need to set the delegate of each textfield to self, like this [textfield setDelegate: self];. I have over 50 textfields in my project and in order to make it so they all dismiss I have to copy that line of code for each textfield. In the example below I used a for loop to try to shrink this down, but my project crashes and gives me this error when I try. Can someone tell me what im doing wrong and how i can fix this?
//.h
#interface InsertScheduleCGPS : UIViewController <UITextFieldDelegate>{
NSArray *Dayh;
IBOutlet UITextField *Day11;
}
#property(nonatomic, assign) id<UITextFieldDelegate> delegate;
#property (nonatomic,strong) NSArray *Dayh;
.
//.m
- (void)viewDidLoad
{
[super viewDidLoad];
Dayh = [NSArray arrayWithObjects:#"Day11", nil];
NSLog(#"euf");
for(int i=0; i<[self.Dayh count]; i++) {
NSLog(#"dd%#",[self.Dayh objectAtIndex:i]);
[[self.Dayh objectAtIndex:i] setDelegate: self];
}
- (BOOL)textFieldShouldReturn:(UITextField *)Day11 {
[[self view] endEditing:YES];
return NO;
}
ERROR:
2014-01-18 19:15:26.712 Swepple[64912:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString setDelegate:]: unrecognized selector sent to instance 0x144ec'
*** First throw call stack:
(
0 CoreFoundation 0x0183b5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x015be8b6 objc_exception_throw + 44
2 CoreFoundation 0x018d8903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0182b90b ___forwarding___ + 1019
4 CoreFoundation 0x0182b4ee _CF_forwarding_prep_0 + 14
5 Swepple 0x0000bbd6 -[InsertScheduleCGPS viewDidLoad] + 4262
6 UIKit 0x00440318 -[UIViewController loadViewIfRequired] + 696
7 UIKit 0x004405b4 -[UIViewController view] + 35
8 UIKit 0x0044f361 -[UIViewController viewControllerForRotation] + 63
9 UIKit 0x00446f00 -[UIViewController _visibleView] + 84
10 UIKit 0x006d511a -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 5199
11 UIKit 0x0044c0fc -[UIViewController presentViewController:withTransition:completion:] + 6433
12 UIKit 0x0044c61f -[UIViewController presentViewController:animated:completion:] + 130
13 UIKit 0x0044c65f -[UIViewController presentModalViewController:animated:] + 56
14 UIKit 0x00870e16 -[UIStoryboardModalSegue perform] + 271
15 UIKit 0x0086107e -[UIStoryboardSegueTemplate _perform:] + 174
16 UIKit 0x00442280 -[UIViewController performSegueWithIdentifier:sender:] + 72
17 Swepple 0x000052d4 -[SecondViewController insert:] + 244
18 libobjc.A.dylib 0x015d0874 -[NSObject performSelector:withObject:withObject:] + 77
19 UIKit 0x0032e0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
20 UIKit 0x0032e04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
21 UIKit 0x004260c1 -[UIControl sendAction:to:forEvent:] + 66
22 UIKit 0x00426484 -[UIControl _sendActionsForEvents:withEvent:] + 577
23 UIKit 0x00425733 -[UIControl touchesEnded:withEvent:] + 641
24 UIKit 0x0036b51d -[UIWindow _sendTouchesForEvent:] + 852
25 UIKit 0x0036c184 -[UIWindow sendEvent:] + 1232
26 UIKit 0x0033fe86 -[UIApplication sendEvent:] + 242
27 UIKit 0x0032a18f _UIApplicationHandleEventQueue + 11421
28 CoreFoundation 0x017c483f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
29 CoreFoundation 0x017c41cb __CFRunLoopDoSources0 + 235
30 CoreFoundation 0x017e129e __CFRunLoopRun + 910
31 CoreFoundation 0x017e0ac3 CFRunLoopRunSpecific + 467
32 CoreFoundation 0x017e08db CFRunLoopRunInMode + 123
33 GraphicsServices 0x037e09e2 GSEventRunModal + 192
34 GraphicsServices 0x037e0809 GSEventRun + 104
35 UIKit 0x0032cd3b UIApplicationMain + 1225
36 Swepple 0x0000e04d main + 141
37 libdyld.dylib 0x01d7c70d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
You probably meant
Dayh = [NSArray arrayWithObjects:Day11, nil];
At present, Dayh is an array containing the string "Day11", not the text field.

MKMapView unexpected crash issue

In viewDidLoad I have only 2 strings:
MKMapView *mapViewMy = [[MKMapView alloc]init];
[self.view addSubview:mapViewMy];
And the app crashed on "[self.view addSubview:mapViewMy]". I use iOS7. It crashes both on devices and simulators. When I use simulator I have crash report:
2013-11-06 13:34:15.948 MyBex JAPanel[36286:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x0216c5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01eef8b6 objc_exception_throw + 44
2 CoreFoundation 0x0211ebcc -[__NSArrayM insertObject:atIndex:] + 844
3 CoreFoundation 0x0211e870 -[__NSArrayM addObject:] + 64
4 UIKit 0x01190b67 PushNextClassForSettingIMP + 358
5 UIKit 0x0118905e TaggingAppearanceObjectSetterIMP + 43
6 UIKit 0x00d6d8de -[UIViewController _setUpLayoutGuideConstraintIfNecessaryAtTop:] + 424
7 UIKit 0x00d6c1c3 -[UIViewController topLayoutGuide] + 140
8 MapKit 0x023d16a8 -[MKMapView updateLayoutGuides] + 82
9 MapKit 0x023d17e7 -[MKMapView didMoveToSuperview] + 68
10 UIKit 0x00cba636 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 472
11 UIKit 0x00cba388 -[UIView(Hierarchy) _postMovedFromSuperview:] + 260
12 UIKit 0x00cc54c1 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1847
13 UIKit 0x00cb89b1 -[UIView(Hierarchy) addSubview:] + 56
14 UIKit 0x01189077 TaggingAppearanceObjectSetterIMP + 68
15 MyBex JAPanel 0x0001180e -[MapViewController configureView] + 142
16 MyBex JAPanel 0x00011778 -[MapViewController viewDidLoad] + 88
17 UIKit 0x00d71318 -[UIViewController loadViewIfRequired] + 696
18 UIKit 0x00d96b15 -[UINavigationController _layoutViewController:] + 39
19 UIKit 0x00d9702b -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 235
20 UIKit 0x00d97123 -[UINavigationController _startTransition:fromViewController:toViewController:] + 78
21 UIKit 0x00d9809c -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
22 UIKit 0x00d98cb9 -[UINavigationController __viewWillLayoutSubviews] + 57
23 UIKit 0x00ed2181 -[UILayoutContainerView layoutSubviews] + 213
24 UIKit 0x00cc8267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
25 libobjc.A.dylib 0x01f0181f -[NSObject performSelector:withObject:] + 70
26 QuartzCore 0x005c82ea -[CALayer layoutSublayers] + 148
27 QuartzCore 0x005bc0d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
28 QuartzCore 0x005bbf40 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
29 QuartzCore 0x00523ae6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
30 QuartzCore 0x00524e71 _ZN2CA11Transaction6commitEv + 393
31 QuartzCore 0x005e1430 +[CATransaction flush] + 52
32 UIKit 0x00c79dc9 _afterCACommitHandler + 131
33 CoreFoundation 0x021344ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
34 CoreFoundation 0x0213441f __CFRunLoopDoObservers + 399
35 CoreFoundation 0x02112344 __CFRunLoopRun + 1076
36 CoreFoundation 0x02111ac3 CFRunLoopRunSpecific + 467
37 CoreFoundation 0x021118db CFRunLoopRunInMode + 123
38 GraphicsServices 0x027f29e2 GSEventRunModal + 192
39 GraphicsServices 0x027f2809 GSEventRun + 104
40 UIKit 0x00c5dd3b UIApplicationMain + 1225
41 MyBex JAPanel 0x0003bc0d main + 141
42 libdyld.dylib 0x03423725 start + 0
43 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I checked, both mapViewMy and self.view are not nil.
Its seems like in our viewDidLoad your object is miss referencing
Make sure you have added Framework of MapKit
Import Map Kit & Delegate in your .h file
Try this code :
MKMapView *mapViewMy = [[MKMapView alloc] initWithFrame:self.view.bounds];
mapViewMy.delegate=self;
[self.view addSubview:mapViewMy];
You need to add map kit delegates methods. :)
in .h file
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
//import MKMapkit framwork
#interface mapSampleViewController : UIViewController {
<MKMapViewDelegate>//mapview delegate
{
MKMapView *mapView;
}
in .m file
add this code in viewdidload
mapView= [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
mapView.delegate = self;
[self.view addSubview:mapView];

Resources