Cannot assign to value: 'self' is immutable
问题 I am trying to return an instance from custom init in subclass of NSMutableURLRequest : class Request: NSMutableURLRequest { func initWith(endPoint:String, methodType:RequestType, body:RequestBody,headers: [String:String]?) { self = NSMutableURLRequest.init(url: URL.init(string: endPoint, relativeTo: URL?)) //return request } } But compiler does not allow to do the same and i get the error "Cannot assign to value: 'self' is immutable". What is the correct way to go about this and why does the