amo*_*mok 0 iphone cocoa cocoa-touch objective-c
下面的代码按预期运行,但编译器一直告诉我:警告:'StatusViewController'可能无法响应'-beginLoadingThreadData'
我如何摆脱这种警告,最重要的是为什么xcode认为是这种情况?
这是我的代码:
[self beginLoadingThreadData]; // called in the loadDidView block
- (void)beginLoadingThreadData
{
[NSThread detachNewThreadSelector:@selector(loadThreadData) toTarget:self withObject:nil];
}
- (void)loadThreadData
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[NSThread sleepForTimeInterval:2];
[self performSelectorOnMainThread:@selector(finishedLoadingThreadData) withObject:nil waitUntilDone:NO];
[pool release];
}
- (void)finishedLoadingThreadData
{
[[BusinessLogic instance] startTracking:self];
}
Run Code Online (Sandbox Code Playgroud)
在使用之前声明该方法.我假设它是一个私有方法,在这种情况下,您将在实现文件的顶部添加一个类扩展:
@interface MyClass ()
- (void) beginLoadingThreadData;
@end
Run Code Online (Sandbox Code Playgroud)
如果它是一个公共方法,请确保您已在标头中声明了该方法并#import编写了实现文件顶部的标题.