0
我爲NSURLSession如何在iOS 7 Objective-C中擺脫此警告?
NSURL * url = [NSURL URLWithString:urlString];
HomeViewController* hvc= [self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];
NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate:hvc delegateQueue: [NSOperationQueue mainQueue]];
NSURLSessionDataTask * dataTask = [defaultSession dataTaskWithURL:url ];
[dataTask setAccessibilityLabel:@"UserProfiling"];
[dataTask resume];
編譯器下面的代碼顯示了這個聲明警告:
NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate:hvc delegateQueue: [NSOperationQueue mainQueue]];
和警告:
Sending 'HomeViewController *' to parameter of incompatible type 'id<NSURLSessionDelegate>'
如何刪除此警告?
我已經書面確認的代表:
@interface ProfileTabView : UIViewController <NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSessionTaskDelegate>
{
}
基本上,我打電話一NSURLSessionDataTask和代表們在其他的ViewController正如你看到的上面。
HomeViewController不是您添加協議一致性的類(ProfileTabView)。 –
很好,趕快,謝謝。我很困惑,因爲代表們出現在不同的ViewController中。 –