0
這是Why do we have to set __block variable to nil?我應該在這裏設置__block變量爲零,爲什麼?
基本上都採用塊可引起ARC保留週期,我還是不明白,爲什麼
-(void)getReviewAndView{
if(![[GrabClass grab] cekInet]){return;}
CM(@"get review and view");
[email protected]"0 view";
[email protected]"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 * [email protected]"review";
NSString * [email protected]"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?
}];
}];
}
啊我明白了。所以如果對象不包含對塊的引用,那麼就不存在真正的問題。謝謝。 –