ios - Swift NSArray out-of-index with no apparent reason -
i'm working popups impressions , did far declaring nsarray
var queue = [popupclass]()
then i'm populating aforementioned array 5 static instances of class right in viewdidload method:
var queue = [pop1, pop2, pop3, pop4, pop5]
i'm putting first element @ bottom of array given amount of times:
for (var = 0; < 12; i++) { queue[0].impression++ queue.append(queue[0]) queue.removeatindex(0) }
this works fine if put instruction line line in viewdidload function. if put same code in method (named refreshimpressions) , recall method still in viewdidload, app crashes because array goes out-of-range @ first element.
override func viewdidload() { super.viewdidload() refreshimpressions() }
any appreciated. sorry if english might sound bad it's not mother language.
Comments
Post a Comment