iOS 9中的Alamofire无法正常工作

时间:2015-09-28 22:41:41

标签: ios json ios9 alamofire

直到iOS 9才能正常工作。我需要做些什么改变才能让它再次运行。 我的self.result是一个JSON数组

func loadData() {
    let url = "https://api.instagram.com/v1/users/self/feed?count=50&access_token=\(accessToken)"

    Alamofire.request(.GET,url).responseJSON{(request,response,json,error) in
        if(json != nil){

            var jsonObject = JSON(json!)
            if let data = jsonObject["data"].arrayValue as [JSON]? {
                self.result = data
                self.numberCells = self.result!.count
                UIView.transitionWithView(self.mycollectionView,
                    duration: 0.40,
                    options: .TransitionCrossDissolve,

                    animations:
                    { () -> Void in
                        self.mycollectionView.reloadData()
                    },
                    completion: nil);
                // self.mycollectionView.reloadData()
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

我使用了下面的Alamofire 3.0 beta,希望对你有所帮助

Alamofire.request(.POST, NetUtils.httpUrl, parameters: parameters, encoding: .JSON).responseJSON{ response in
//            print("request=\(response.request)")
//            print("response=\(response.response)")
//            print("result=\(response.result)") 
            if response.result.isSuccess{
                let jsonStr = response.result.value
                print(jsonStr)
                if let loginModel = Mapper<LoginModel>().map(jsonStr) {
                    if let _ = loginModel.status?.toBool(){
                        print("hello")
                    }
                    print(loginModel.object?.uname)
                }

            }
        }
相关问题