ios - Can't use reloadData from another class -
i have 2 classes, classa , classb in classa have tableview works , refreshes on demand. delegates , datadource fine , there's property @property (nonatomic, retain) uitableview *mytableview;
i don't want set reloaddata
in viewdidappear or viewwillappear of classa. want fire [mytable reloaddata]
classb.
thanks
use delegates reload tableview.
in class tableview is, write in viewdidload:
[[nsnotificationcenter defaultcenter] removeobserver:self name:@"updatelefttable" object:nil]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(checkres:) name:@"updatelefttable" object:nil];
then in same class implement function so:
-(void)checkres:(nsnotification *)notification { if ([[notification name] isequaltostring:@"updatelefttable"]) { [_reartableview reloaddata]; } }
finally, in class want reload tableview paste next line (it's of import line goes in method want reload tableview):
[[nsnotificationcenter defaultcenter] postnotificationname:@"updatelefttable" object:self];
tell me if have problems.
ios objective-c cocoa-touch cocoa
No comments:
Post a Comment