Error while using Sttwitter and Swifter

Asked

Viewed 77 times

0

I am trying to use one of the two libraries Sttwitter or Swifter in my project but always 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 the Xcode keeps complaining "Missing argument for parameter 'sinceID' in call" only it does not have this parameter in the method..

Follow the code:

    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 importing it into the project it gives build error in the String+Swifter class.

I’m using Xcode 6.1.1 with iOS SDK 8.1 I’m doing something wrong?

  • 1

    This library is from Objective-C. Have a look at how to integrate Objective-C with Swift: http://answall.com/questions/47238/como-integrar-objective-c-e-swift

  • The problem is not in the integration. I already created the Bridging Header file I made the import. In the case of lib Sttwitter the problem is only in the call of that method I mentioned, because I use another method before to pass the two keys and works normally.

1 answer

0

In Swift one 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. As there is already the 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 gets:

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

got it?

See more in that excellent OS response (in English).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.