我有以下功能:prepare()
其中返回NSMUtableArray
。當我嘗試,返回一個json
是NSMutableArray
對象,我得到以下錯誤:iOS中的函數返回錯誤
'NSMutableArray' is not convertible to 'Void'
功能的源代碼:
func prepare() -> NSMutableArray {
let statusesShowEndpoint = "https://api.twitter.com/1.1/statuses/user_timeline.json"
let params = ["screen_name": "tikaDotMe"]
var clientError : NSError?
let request = Twitter.sharedInstance().APIClient.URLRequestWithMethod(
"GET", URL: statusesShowEndpoint, parameters: params,
error: &clientError)
if request != nil {
Twitter.sharedInstance().APIClient.sendTwitterRequest(request) {
(response, data, connectionError) -> Void in
if (connectionError == nil) {
var jsonError : NSError?
let json = NSJSONSerialization.JSONObjectWithData(data,
options: nil,
error: &jsonError) as NSMutableArray
//Error: 'NSMutableArray' is not convertible to 'Void'
return json
}
else {
println("Error: \(connectionError)")
}
}
}
else {
println("Error: \(clientError)")
}
return [""]
}
您正在使用哪種版本的XCode? – user3581203
@ user3581203版本6.1.1(6A2008a) – tika