Why in swift we cannot adopt a protocol without inheritance a class from NSObject?
swift
Solution
`NSURLConnectionDataDelegate` itself inherits from `NSURLConnectionDelegate` which inherits from `NSObjectProtocol`.
That means that apart from implementing all the methods from `NSURLConnectionDataDelegate`, and `NSURLConnectionDelegate`, you also have to implement all the methods from `NSObjectProtocol` (e.g. equality, hash).
You didn't implement them, that's your mistake. If you inherit from `NSObject`, all that `NSObjectProtocol` methods are already implemented for you.
Problem
If i use the following code it shows me error "Type 'HttpConnection' does not conform to protocol 'NSObjectProtocol'" ``` class HttpConnection : NSURLConnectionDataDelegate { var urlConnection : NSURLConnection? weak var delegate : HttpConnecting? init(delegate:HttpConnecting){ self.delegate = delegate; } func startAsynRequestWithUrlString(url:NSString, withMethod:NSString){ } } ``` If i subclass HttpConnection to NSObject then it works fine. So my question is when i need to adopt NSURLConnectionDataDelegate protocol in swift why i need to inherit the class from NSObject?