New to Twitter REST api having problems! Help?


I am trying to learn with the default example on the site . I pasted the code as it is in my swift file But getting error “Cannot use instance member ‘client’ within property initializer; property initializers run before ‘self’ is available”

import UIKit
import TwitterKit

class TweetsViewViewController: UIViewController {
    override func viewDidLoad() {

        // Do any additional setup after loading the view.
    let client = TWTRAPIClient()
    let statusesShowEndpoint = ""
    let params = ["id": "20"]
    var clientError : NSError?
//here is the error !
    let request = client.urlRequest(withMethod: "GET", url: statusesShowEndpoint, parameters: params, error: &clientError)
    client.sendTwitterRequest(request) { (response, data, connectionError) -> Void in
    if connectionError != nil {
        print("Error: \(String(describing: connectionError))")
    do {
        let json = try JSONSerialization.jsonObject(with: data!, options: [])
        print("json: \(json)")
    } catch let jsonError as NSError {
        print("json error: \(jsonError.localizedDescription)")



Did you initialise Twitter Kit first, and setup Info.plist?


Sir The Thing is that once i put that data into the method (function another function ) then it is working ! So no problem now i got this from your code example on github ! Thank you !