I'm trying to load data from API and show it inside a UITableView
. I used AFNetworking
for the network calls, but now I'm facing a problem: I can't access myTableView
nor self
inside the 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 the code shows that inside the block I can't access any of self
, myDataSource
, or myTableView
.
How can I solve this issue?
Thanks.