Wednesday, 15 September 2010

ios - Passing an NSArray from a UIViewController to a subview -



ios - Passing an NSArray from a UIViewController to a subview -

this question has reply here:

can't impact uitextview content initwithcoder 1 reply passing info between view controllers 33 answers

i having problem simple task of passing nsarray parent uiviewcontroller downwards subview, uiview.

here code...

i declare subview (a subclass of uiview). in view controller when storyboard initialises, pass array downwards subview. log array, , console tells me (null).

parentviewcontroller.h

@property (nonatomic, strong) iboutlet apcolumntableview *tableview;

parentviewcontroller.m

-(id)initwithcoder:(nscoder *)adecoder { self = [super initwithcoder:adecoder]; if (self) { nsarray *array = [nsarray arraywithobjects:@"1", @"2", @"3", @"4", nil]; [_tableview setcolumntitles:array]; nslog(@"%@", _tableview.columntitles); } homecoming self; }

i have added uiview in storyboard uiviewcontroller, set subclass , connected iboutlet. have declared columntitles nsarray can see.

apcolumntableview.h (my subview subclass)

@property (nonatomic, strong) nsarray *columntitles;

then in .m file, log array 1 time again see console spits out, still (null).

apcolumntableview.m

-(void)awakefromnib { //intialisation here... nslog(@"%@", self.columntitles); }

where going wrong?! want pass nsarray downwards uiviewcontroller subview.

none of outlets going set yet in initwithcoder:. utilize awakefromnib or viewdidload pass array. if log _tableview in initwithcoder:, it's going nil.

ios cocoa-touch uiview uiviewcontroller iboutlet

No comments:

Post a Comment