swift - Alamofire: Cannot invoke 'URLRequest' with an argument list of type '(Method, NSURL)' -


i playing request router pattern, looks this:

enum router: urlrequestconvertible {  static let baseurlstring = "https://somewhere"  case dosomething  var urlrequest: nsurlrequest {     let (method: method, path: string, parameters: [string: anyobject]) = {         switch self {         case .dosomething:             var params = [string: anyobject]()             return (.get, "/dosomething", params)         }     }()      let url = nsurl(string: router.baseurlstring)!.urlbyappendingpathcomponent(path)      let request = urlrequest(method, url)  // <- error here      let encoding = parameterencoding.url      return encoding.encode(request, parameters: parameters).0 } } 

and i'm getting aforementioned "cannot invoke 'urlrequest' argument list of type '(method, nsurl)'"

looking @ method signature of urlrequest see:

func urlrequest(method: method, url: urlstringconvertible) -> nsurlrequest

nsurl conforms urlstringconvertible protocol, should good. isn't. now, here strange part:

if cut , paste urlrequest same file enum, adjust name making urlrequestt (to avoid conflicting original), , use function instead, compiler errors go away.

i have copied alamofire swift files project because targeting ios 7, might factor. i'm not using embedded framework.

so, question is: why code throw compiler error , why copy/pasting/renaming urlrequest function cause work?

if use alamofire framework within project, won't have visibility urlrequest function, because not public. can either make public (i'm not crazy forking afnetworking trivial), or can implement copy of function in module.

i experimented, though, using alamofire source right within project, , see same curious behavior describe. can circumvent this, either including copy of function within source file (as described) or bypass completely:

let request = nsmutableurlrequest(url: url) request.httpmethod = method.rawvalue 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -