我在8号线上遇到错误"额外的参数'错误'在通话中。有什么建议吗?
@IBAction func loadFollowers(sender:AnyObject) {
Twitter.sharedInstance().APIClient.sendTwitterRequest(Twitter.sharedInstance().APIClient.URLRequestWithMethod("GET", URL: "https://api.twitter.com/1.1/friends/ids.json", parameters: ["user_id":Twitter.sharedInstance().session()!.userID], error: nil), completion:
{(response:NSURLResponse?, data:NSData?, error:NSError?) -> Void in
var dic = NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.AllowFragments, error: nil) as! NSDictionary
var friends = dic["ids"] as! NSArray
self.following = friends
Twitter.sharedInstance().APIClient.sendTwitterRequest(Twitter.sharedInstance().APIClient.URLRequestWithMethod("GET", URL: "https://api.twitter.com/1.1/followers/ids.json", parameters: ["user_id":Twitter.sharedInstance().session()!.userID], error: nil), completion: {(resonse:NSURLResponse?,data:NSData?,error:NSError?) -> Void in
var dic = NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.AllowFragments, error: nil) as! NSDictionary
var followers = dic["ids"] as! NSArray
self.followers = followers
for id in self.following {
if !self.followers.containsObject(id)
{
var st = id as! NSNumber
Twitter.sharedInstance().APIClient.loadUserWithID(st.stringValue, completion: {(user:TWTRUser?,error:NSError?) -> Void in
self.results.addObject(user!)
//self.tableView.reloadData()
print("done")
})
}
}
})
})}
答案 0 :(得分:2)
在Objective-C中,这曾经是可能的,现在你必须做这样的事情:
do{
let dict = try NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments) as! NSDictionary
}catch let error{
print(error)
}