objective c - Type Error in closure (translated code from obj c to swift) -


I am trying to use a library which is written in Objective-C in my Quick App. I tried to translate a snippet with swift code - but I get a type of error that I do not understand.

Obj.C code from readme:

  [Self.client logonWithUsername: self.username.text password: self.password.text responseClallback: ^ (NSDictionary * response, NSError * error) {if (error) {[self handleFailedAuth: error]; Return; } [Self-handling successful operation]; }];  

My translation swift:

  var user name = NSUserDefaults.standardUserDefaults (). StringForKey ("username") var password = NSUserDefaults.standardUserDefaults (). {HandleFailedAuth (error));} handleSuccessfulAuth ()}) If the (error) in StringForKey ("password") client.logonWithUsername (username, password: password, feedback callback: {(response: NSDictionary, error: NSError) Code>  

I get [NSObject: AnyObject]! A subtype of the expression is not on the line, where the parameters of the band are defined. How is that possible? I am using the same type as an example.

Your SWIFT should read the following: < / Pre>

The reason for this is that in some ways the Swift option is the way you use it to pass zero in Objective-C Place L'replaced because NSDictionary be zero and NSError be zero, after one of his? -If the mark, then to conditionally open the block within the w / a! -mark when you need to use that value


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -