【问题标题】:Alamofire in iOS 9 Not workingiOS 9 中的 Alamofire 不工作
【发布时间】:2015-09-28 22:41:41
【问题描述】:

这在 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()
            }
        }
    }
}

【问题讨论】:

标签: ios json ios9 alamofire


【解决方案1】:

我使用了 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)
                }

            }
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-16
    • 2016-04-24
    • 2015-12-15
    • 2018-12-06
    相关资源
    最近更新 更多