ios - removeAllObjects crashes app -


I want to clear my array, what have I done,

tableview view in my app First, I am bringing data from the server and loading it in Table Weave.

  - (zero) viewDidoad is bringing data from the server using the {// background thread and is stored in the array (msg_array) [table reloadData]; }  

When the last line appears on the screen, I want to get new data from the server and I want to display it,

  - (zero This method is ignored if the LoadMoradata is on the final method screen ([msg_array count]] gt; {[msg_array removeAllObjects]; // crash here}}  

Gives the error:

  Ending the application 'NSInvalidArgumentException' due to an incomplete exception, Reason: '- [__NSArrayI removeAllObjects]  

This is an accident car Why is:

The array is allocated in such a way:

  msg_array = [copy dickshaw];  

Is included and it has been copied to msg_array and dictshow.

(taken from)

'- [__ NSARA deleted all object]: Send to unknown selector for example

This means that the array does not have the way you call Are trying to do ace Because it is an immutable array ( NSArray ), is not volatile ( NSMutableArray ).

Either you can change it if you want to change it or, replace:

  [msg_array removeAllObjects]; With  

:

  msg_array = @ [];  

Depending on your comment, the array must be volatile. This means that you have an unstable property / instance variable, but you're making a temporary example to store in it. Search and update that location (at least one mutableCopy to create / return).


Comments