Swift - Append object: array index out of range -
when try add item array gives me , exc bad instruction error , says
fatal error: array index out of range
that code:
var tabelle : [[actions]] = [[]] func dosomething() { var results = self.fetch() var oldprojektname: string = results[0].projektname var count: int = 0 item in results { if oldprojektname == item.projektname { tabelle[count].append(item) } else { count++ tabelle[count].append(item) } oldprojektname = item.projektname } }
as long count = 0 not give me error when count = 1 app crashes.
you have array 1 element: var tabelle : [[actions]] = [[]]
why tabelle[0] working.
you need append array tabelle before can use tabelle[1]
Comments
Post a Comment