how do i parse an array inside parsed json in swift using -'ios,json,swift'

how do i parse an array inside parsed json in swift  using -'ios,json,swift'

I'm using an API that returns JSON that looks like this


In Swift I use two functions to get and then parse the JSON

func getJSON(urlToRequest: String) -> NSData{
    return NSData(contentsOfURL: NSURL(string: urlToRequest))

func parseJSON(inputData: NSData) -> NSDictionary{
    var error: NSError?
    var boardsDictionary: NSDictionary = NSJSONSerialization.JSONObjectWithData(inputData, options: NSJSONReadingOptions.MutableContainers, error: &error) as NSDictionary
    return boardsDictionary

and then I call it using

var parsedJSON = parseJSON(getJSON("link-to-API"))

The JSON is parsed fine. When I print out


I get all the contents of the array. However I am unable to access each individual index. I'm positive it IS an Array, because ween I do


the correct length is returned. However if I attempt to access the individual indices by using


XCode turns off syntax highlighting and gives me this:

and the code won't compile.

Is this a bug with XCode 6, or am I doing something wrong?

asked Sep 7, 2015 by rajesh
0 votes

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.