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?