ios - Getting error for passed in UserId in tab controller? -
i not sure why keep getting error, pass userid profile view controller on button click push:
totaltabcontroller *usertabview = [[uistoryboard storyboardwithname:@"main" bundle:nil] instantiateviewcontrollerwithidentifier:@"usertabview"]; usertabview.userprofileid = userid; nslog(@"the user tota tab %@", userid); usertabview.userprofilename = profilename; [self.navigationcontroller pushviewcontroller:usertabview animated:no];
the nslog prints out correct userid, , have added tab controller in .h file so:
@interface totaltabcontroller : uitabbarcontroller { nsstring *userprofileid, *userprofilename; } @property (nonatomic, retain) nsstring *userprofileid; @property (nonatomic, retain) nsstring *userprofilename;
and in .m file so:
@synthesize userprofileid, userprofilename; - (void)viewdidload { [super viewdidload]; nslog(@"the tab loaded , %@", userprofileid); }
but nslog prints out null in .m file...
then call in 1 of tab views .m file so:
userprofileid = [(totaltabcontroller*)self.tabbarcontroller userprofileid];
and error:
the error is:
2014-05-17 11:49:04.667 example[1108:60b] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[__nsplaceholderdictionary initwithobjects:forkeys:count:]: attempt insert nil object 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 uncaught exception of type nsexception (lldb)
the ultimate goal pass userid profile.m file tab controller , allow each tab have access userid, not sure doing wrong, if can notice error or let me know how can have not null , accessible?
update thinking maybe has not being able push tabcontroller according apple's guidelines, case? if how go around it, or options have?
hi problem here trying push tab bar controller in navigation controller apple forbids link .so can add tabbar controller modally or create custom tab bar in view controller , push it
Comments
Post a Comment