objective c - ios: Updating UITableView inside AFNetworking success callback -
i'm trying load data api , show inside uitableview. used afnetworking network calls, i'm facing problem: can't access mytableview nor self inside success block.
@property (weak, nonatomic) iboutlet uitableview *mytableview; @property (nonatomic,retain) nsmutablearray *mydatasource; @synthesize featuredproductstableview; - (void)viewdidload { [super viewdidload]; networkmanager *networkmanager = [networkmanager getinstance]; mydatasource = [nsmutablearray array]; [networkmanager getpath:@"example.com" parameters:nil success:^(afhttprequestoperation *operation, id json) { [mydatasource addobjectsfromarray:json]; [mytableview reloaddata]; } failure:^(afhttprequestoperation *operation, nserror *error) { nslog(@"%@",error); }]; } debugging code shows inside block can't access of self, mydatasource, or mytableview.
how can solve issue?
thanks.
you should use :
__block mydatasource = [nsmutablearray array]; you can read: