import UIKit import Alamofire class Model: NSObject { private var youtubeNextPageToken: String? func loadYoutubeList(callback: (youtubeList: YoutubeList) -> (), fail:((error: NSError) ->())){ let req = request(.GET, AppConfig.youtubeURL()) req.response { (request, response, responseData, error) -> Void in do { let jsonResult = try NSJSONSerialization.JSONObjectWthData(responseData!, options: NSJSONReadingOptions.MutableContainers) as! NSMutableDictionary self.youtubeNextPageToken = jsonResult["nextPageToken"] as! String? let ary = jsonResult["items"] as! NSArray let youtubeList = YoutubeList(ary: ary) callback(youtubeList: youtubeList) } catch { print("loadYoutubeList error") } } } }
constrainをつけて行きます。