基本上使用块会导致 ARC 中的保留周期,我仍然不太明白为什么
-(void)getReviewAndView{
if(![[GrabClass grab] cekInet]){return;}
CM(@"get review and view");
self.viewlbl.text=@"0 view";
self.reviewlbl.text=@"0 review";
Business * businessReviewed = [BNUtilitiesQuick currentBusiness];
NSString *alamat=[NSString stringWithFormat:@"http://...",businessReviewed.ID];
CLog(@"alamat:%@", alamat);
__block NSDictionary * dic = nil;
[Tools doBackground:^{
dic=(NSDictionary *)[GrabClass JsonParser:alamat]; //dic get set here
[Tools doForeGround:^{
NSString *countView= [[dic objectForKey:businessReviewed.ID] objectForKey:@"CountViews"];
CLog(@"countView:%@", countView);
NSString *countReview=[[dic objectForKey:businessReviewed.ID] objectForKey:@"Review"]; //dic get used here
NSString * reviews=@"review";
NSString * view=@"view";
//blablabla
self.viewlbl.text=[NSString stringWithFormat:@"%@ %@",countView,view ];
self.reviewlbl.text=[NSString stringWithFormat:@"%@ %@",countReview,reviews];
dic =nil; //should this be called? What happen if it doesn't?
}];
}];
}