NSMutableArray addObject not working

前端 未结 2 1928
时光说笑
时光说笑 2020-11-22 01:07

I have declared an NSMutableArray *categories in my view controller .h file, and declared a property for it.

In the parser:foundCharacters:

相关标签:
2条回答
  • 2020-11-22 01:41

    Initialize an empty array using

    categories = [NSMutableArray array];
    

    The array class method are autoreleased so no need to release.

    0 讨论(0)
  • 2020-11-22 01:54

    The "0x0" part is a memory address. Specifically, "nil", which means your mutable array doesn't exist at the time this is being called. Try creating it in your -init method:

    categories = [[NSMutableArray alloc] init];
    

    Don't forget to release it in your -dealloc.

    0 讨论(0)
提交回复
热议问题