Reputation: 370
What will happen if below codes execute?
NSData* data = [myArray objectAtIndex:i] // assigning from array
[myArray removeAllObjects]; // removing all objects from array.
[self doSomething:data]; // this method will execute some operations with data
Is data turned into a zombie object which might cause EXC_BAD_ACCESS crash?
Upvotes: 0
Views: 62
Reputation: 394
No it wouldn't cause a crash. Your data
is just a pointer, holding the same numerical (virtual) memory address where the NSData data is stored. If one of the pointers is set to point to nil, or to some other data for that matter, it won't trigger any change in the NSData nor the other pointer.
Upvotes: 1