Can a variable bu used 2nd time after releasing it?
Posted
by Jakub
on Stack Overflow
See other posts from Stack Overflow
or by Jakub
Published on 2010-04-11T13:59:46Z
Indexed on
2010/04/11
14:03 UTC
Read the original article
Hit count: 288
Hello,
I try to understand the memory management in ObjectiveC and still some things are a misery for me. I've got an instance variable:
NSMutableArray *postResultsArray;
when a button is clicked in the UI I create new array:
self.postResultsArray = [NSMutableArray array];
then I add some objects to the array and when the whole operation is done I would like to release the array:
[self.postResultsArray release];
(I assume that all the objects stoed in the array will be released along with the array). The problem appears when I click the button again and in the code I want to create the array again with:
self.postResultsArray = [NSMutableArray array];
I get:
[CFArray release]: message sent to deallocated instance 0x3d9e390
Can't I initialize the same instance variable for the second time? or maybe I should not release it? and if so, why?
Thanks!
© Stack Overflow or respective owner