NSMutableArray count always returns zero

前端 未结 3 1601
無奈伤痛
無奈伤痛 2021-01-12 13:09

I\'m sure I\'m doing something silly, but this is driving me crazy.

I\'m trying to loop through database results, create objects from those results, and add the obje

3条回答
  •  余生分开走
    2021-01-12 13:12

    A few things:

    1. What happens if you put an NSLog call inside of the while loop? Verify that loop iterations are actually happening before blaming it on the array.
    2. Where are you creating the array hiragana? If you are doing it incorrectly for some reason and the array is nil, it might cause problems like this.
    3. If you do not have garbage collection on, be sure to do [htemp release] after adding it to the loop. addObject retains and each added item will leak from the loop. Again, this is only relevant if garbage collection is off.

    It's most likely either you aren't created the array correctly or rs doesn't contain what you expect it to contain, and so [rs next] isn't getting called ever (if rs is nil, for example, no iterations of this loop would execute and you wouldn't have any sort of error).

提交回复
热议问题