开发者

Initialization of NSMutableArray in a loop

开发者 https://www.devze.com 2023-03-14 10:46 出处:网络
I have an IBAction like this: if([checkinArray count]!=0){ [checkinArray removeAllObjects]; } loop{ Checkin *checkinsA = [[Checkin alloc] init];

I have an IBAction like this:

if([checkinArray count]!=0){
        [checkinArray removeAllObjects];
 }
loop{
    Checkin *checkinsA = [[Checkin alloc] init];
    .....
   [checkinArray addObject:checkinsA];
    [checkinsA release];

}

And when checkinArray is not empty I am getting exc bad access error and the app is crashing. What I am doing wrong here? What I am trying to do is to empty the array and then refill ti with updated data. PS. The checkin array is de开发者_运维技巧clared in .h and is initialized on viewdidload.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号