Also versuche ich einige Daten in JSON mit Swift zu analysieren. mein Code unten istNSDictionary in Swift: Kann einen Wert vom Typ 'AnyObject' nicht subskribieren? mit einem Index vom Typ 'Int'
var jsonResult:NSDictionary! = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil) as! NSDictionary
println(jsonResult)
Der obige Code werde ich versuchen, dann so etwas wie dieses
{
count = 100
subjects = (
{
alt = "....."
name = "....."
},
{
alt = "....."
name = "....."
},
......
)
}
Rückkehr alle Fächer mit jsonResult["subjects"]
zugreifen zu können, so weit so gut Aber wenn ich versuche, Zugriff auf das einzelne Thema, zum Beispiel jsonResult["subjects"][0]
, Xcode gibt mir Fehler: Cannot subscript a value of type 'AnyObject?' with an index of type 'Int'
Kann mir jemand dabei helfen?
Vielen Dank, total funktioniert – JSNoob