简体   繁体   English

如何在iOS 7 Objective-C中摆脱此警告?

[英]How do I get rid of this warning in iOS 7 Objective-C?

I have the following code for NSURLSession 我为NSURLSession使用以下代码

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];

The compiler shows a warning at this statement: 编译器在以下语句中显示警告:

NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate:hvc delegateQueue: [NSOperationQueue mainQueue]];

and the warning is : 并且警告是:

Sending 'HomeViewController *' to parameter of incompatible type 'id<NSURLSessionDelegate>'

How do I remove this warning? 如何删除此警告?

I have confirmed to the delegates by writing: 我已通过书面确认与会代表:

@interface ProfileTabView : UIViewController <NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSessionTaskDelegate>
{

}

Basically, I am calling a NSURLSessionDataTask and the delegates are in another ViewController as you see above. 基本上,我正在调用NSURLSessionDataTask,并且委托在另一个ViewController中,如您在上面看到的。

(From a comment, making answer for posterity.) (摘自评论,为后人作答。)

HomeViewController is not the class you've added the protocol conformance to (ProfileTabView). HomeViewController不是您向(ProfileTabView)添加协议一致性的类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM