###前提・実現したいこと
getリクエストを送信し、受け取った配列[{},{},{},{},{}...]の形のものを展開し、TableViewCellに表示したいのですが、うまくいきません。
###発生している問題・エラーメッセージ
エラーメッセージとして[__NSArrayM objectAtIndex:]: index 3 beyond bounds for empty array'
が表示されています。
Dictionaryの中のArrayを展開することはできそうな気がするのですが、Arrayの中のDictionaryを展開することはできるのでしょうか。。。
どなたかご回答よろしくお願いいたします。
###ソースコード
var basicscript = NSArray()
var getUrlString = "http://IP/show/" + String(number1)
override func viewDidLoad() { super.viewDidLoad()
let url = NSURL(string: getUrlString)!
var task = NSURLSession.sharedSession().dataTaskWithURL(url, completionHandler: {data, response, error in // conver json to dictionary do { var dict = try! NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) as! NSArray if var aaa = dict[1] as? NSArray { // set array of entries } }catch { } }) task.resume() } //count cell of table view func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return basicscript.count } //make tableView func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { //get cell let basiccell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "basiccell") //get basicscript var aaa = (named:basicscript[indexPath.row] as! NSArray) basiccell.textLabel!.text = aaa[1] as! String return basiccell }
###補足情報(言語/FW/ツール等のバージョンなど)
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。