31 Jul '15, 12pm

「サッカーのスコアを通知するモバイル・アプリを IBM Bluemix 上で作成する」を公開しました。 #Bluemix #MongoDB #Ruby #Sinatra #ibmdW #dWJapan

import Foundation protocol ScoreAPIControllerProtocol { func didReceiveScores(scores: NSArray) } class ScoreAPIController { var delegate: ScoreAPIControllerProtocol? init() { } func getScores(date: NSString) { let urlPath = "http://occer.mybluemix.net/?date=\(date)" let url = NSURL(string: urlPath) let session = NSURLSession.sharedSession() let task = session.dataTaskWithURL(url!, completionHandler: {data, response, error -> Void in if(error != nil) { println(error.localizedDescription) } var err: NSError? var jsonResult = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: &err) as NSArray self.delegate?.didReceiveScores(jsonResult) if(error != nil) { println("JSON Error \(err!.localizedDescription)") } }) task.resume() } }

Full article: http://www.ibm.com/developerworks/jp/mobile/library/mo-bl...

Tweets