0
如何解決這個錯誤如何將這個objc轉換爲SWIFT
func loginMobilephone(phone : String , password : String , withBlock block : ((result:NSDictionary , error: NSError)-> Void)!)
{
var params : AnyObject! = ["username" :phone,"passwd": password, "session_id" : Constant.instance().session]
var path : String! = "/account/common/login";
NetworkManager.sharedClient().postPath(path, parameters: params, withBlock: block)
NetworkManager.sharedClient().postPath(<#path: String!#>, parameters: <#[NSObject : AnyObject]!#>, withBlock: <#(([NSObject : AnyObject]!, NSError!) -> Void)!##([NSObject : AnyObject]!, NSError!) -> Void#>)
}
錯誤是:
Cannot invoke 'postPath' with an argument list of type '(String!, parameters: AnyObject!, withBlock: ((result: NSDictionary, error: NSError) -> Void)!)'
或如何將其轉換爲SWIFT
+(void)loginMobilephone:(NSString *)phone password:(NSString *)password withBlock:(void (^)(NSDictionary *, NSError *))block{
NSDictionary *params = @{@"username" : phone,
@"passwd" : password,
@"session_id":[[Constant instance] session]
};
[[NetworkManager sharedClient] postPath:APIUSERLOGIN parameters:params withBlock:block]; }