简而言之,我需要知道我是否能够记录变量的存储类型。
具体来说,我想记录一个变量是否__block
应用了存储类型修饰符。
理想情况下,我正在寻找类似的东西:
NSLog(@"storage type: %@", [localVar storageType]);
如果您想知道,我想我刚刚发现了过去几天一直在调试的内存泄漏,我想测试我的假设是否正确。
我将 ASIHttpRequest 与setCompletionBlock
and一起使用setFailedBlock
,但我将我的请求对象传递给一个方便的方法,该方法执行块的实际设置,如下所示:
- (void)getAllHighlights:success:(ASIBasicBlockWrapper)cb1 fail:(ASIBasicBlockWrapperFail)cb2{
// blah blah blah
__block ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setRequestMethod:@"GET"];
[request setDelegate:self];
[self executeAsynchronousRequest:request onSuccess:cb1 onFail:cb2];
}
然后,executeAsynchronousRequest
设置块并启动请求:
- (void) executeAsynchronousRequest:(ASIFormDataRequest *)request onSuccess:(ASIBasicBlockWrapper)cb1 onFail:(ASIBasicBlockWrapperFail)cb2
{
[request setCompletionBlock:^{
int statusCode = [safeRequest responseStatusCode];
NSString *statusMessage = [self statusErrorMessage:statusCode];
cb1([safeRequest responseString],statusMessage);
}];
[request setFailedBlock:^{
cb2(safeRequest);
}];
[request startAsynchronous];
}
我的直觉告诉我,即使我将请求对象设置为__block ASIFormDataRequest *request
,当它在 内使用时executeAsynchronousRequest
,它也丢失了 __block 存储类型,因为它只被键入为(ASIFormDataRequest *)request
.
谢谢!