ios - Updating UIView with data of another Class -
i have classa , classb, want pass data classb , update existing uiview of instance of classa.
what i'm doing instantiating classa in classb , calling updatelabel:
classa *obj = [[classa alloc] init]; [obj updateview:value]; it's not working ! think because updatelabel called on instance of classa uiview nil. right?
what way make work?
ps: i'm doing way because value update set when method of classb triggered.
if want update data in class can use nsnotificationcenter or delegate
in class @ time of initialisation.
-(void)viewdidload{ [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(labelupdate:) name:@"noficationname" object:nil]; } -(void)labelupdate:(id)sender{ //do update stuff. } call in class b when want update class
[[nsnotificationcenter defaultcenter] postnotificationname:@"noficationname" object:nil];
Comments
Post a Comment