为了账号安全,请及时绑定邮箱和手机立即绑定

求大神解答一下,success和failure,在我的Xcode6 beta2里一直报错,有以下几个错:

manager.GET(url,    

parameters: params,    

success: { (operation: AFHTTPRequestOperation!,    

responseObject: AnyObject!) in    

println("JSON: " + responseObject.description!)    


self.updateUISuccess(responseObject as NSDictionary!)    

},    

failure: { (operation: AFHTTPRequestOperation!,    

error: NSError!) in    

println("Error: " + error.localizedDescription)    


self.loading.text = "Internet appears down!"    

})    

1. 是不是必须写'in println()' , 否则s会报错

2. success里面写'in println()', 编译器就崩溃了,会有一大片内存的报错信息

3. 要是这样写

success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!)

                self.updateUISuccess(responseObject as NSDictionary!)},

failure: { (operation: AFHTTPRequestOperation!,error: NSError!) in println("hello")})

在success的左大括号处报Function produces expected type '((AFHTTPRequestOperation!, AnyObject!) -> Void)!'; did you mean to call it with '()'?

4. 要是这样写

success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!)

                             self.updateUISuccess(responseObject as NSDictionary!)},

failure: { (operation: AFHTTPRequestOperation!, error: NSError!)  })

在failure的AFHTTPRequestOperationNSError都报:Expected member name or constructor call after type name


正在回答

1 回答

请使用Xcode beta6,并参考Github的代码,由于苹果已经修改了Swift的语法,没必要继续用老的语法。

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Swift Weather APP
  • 参与学习       35561    人
  • 解答问题       241    个

本课程将带领大家使用Swift语言开发一个完整的天气 iOS APP

进入课程
意见反馈 帮助中心 APP下载
官方微信