Error when using STTwitter and Swifter

0

I'm trying to use one of the two STTwitter or Swifter libraries in my project but always the error.

In the case of STTwitter the error is in the method call getUserTimelineWithScreenName:(NSString *)screenName successBlock:(void(^)(NSArray *statuses))successBlock errorBlock:(void(^)(NSError *error))errorBlock;

What happens is that Xcode keeps complaining "Missing argument for parameter 'sinceID' in call" only does not have this parameter in the method ..

Follow the code below:

    twitter.verifyCredentialsWithSuccessBlock({ (username: String!) -> Void in

            twitter.getUserTimelineWithScreenName(
                screenName: "gregoryfm",
                successBlock: { (status: Array!) -> Void in
                    println("deu certo")
                },
                errorBlock: { (error: NSError!) -> Void in
                    println("verifyCredentialsWithSuccessBlock error:  \(error.description)")
                })
        },
        errorBlock: { (error: NSError!) -> Void in
            println("verifyCredentialsWithSuccessBlock error:  \(error.description)")
        })

And when testing Swifter when I import it into the project it gives compilation error in the String + Swifter class.

I'm using Xcode 6.1.1 with the iOS SDK 8.1 Am I doing something wrong?

    
asked by anonymous 16.01.2015 / 23:31

1 answer

0

In Swift you should not put the label of the first parameter as we see in documentation

This occurs for the reading to be the same as Objective-C. Since there is already screenName in the method name it should not be specified.

Just remove screenName: and your code will work!

For example, the Objective-C code

[twitter getUserTimelineWithScreenName: name successBlock: successBlock errorBlock: errorBlock];

In Swift stands:

twitter.getUserTimelineWithScreenName(name, successBlock: successBlock, errorBlock: errorBlock)

Do you understand?

See more this excellent response from the OS.

    
19.01.2015 / 20:53