I am using AFNetworking 2.3.1
:
let request = NSURLRequest(URL: NSURL(string: "http://xxx.xxx.xxx/xxx")!)
var requestOperation = AFHTTPRequestOperation(request: request)
requestOperation.responseSerializer = AFImageResponseSerializer()
I have an error at third line using Swift 1.1 (Xcode 6.1 beta 2 build 6A1030):
'init()' is unavailable: superseded by import of -[NSObject init]
This line should looks like this on Objective-C:
requestOperation.responseSerializer = [AFImageResponseSerializer serializer];
I think this problem is related to Swift auto-bridging from Objective-C. Any ideas to solve this?
UPDATE:
This way doesn't works:
AFImageResponseSerializer.serializer()
And error description is very nice:
'serializer()' is unavailable: use object construction 'AFHTTPResponseSerializer()'
UPDATE 2:
Right now I found a temporarily solution. I added this code to bridging header:
@interface AFImageResponseSerializer (CustomInit)
+ (instancetype)sharedSerializer;
@end
and code added to "bridging-header" implementation file:
@implementation AFImageResponseSerializer (CustomInit)
+ (instancetype)sharedSerializer {
return [AFImageResponseSerializer serializer];
}
@end
And used it like this:
AFImageResponseSerializer.sharedSerializer()
It was caused by becoming stricter of conversion to the base class in XCode 6.1. So, you need upcasting, like below.
requestOperation.responseSerializer = AFImageResponseSerializer() as AFHTTPResponseSerializer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With