Suppose I create several objects and add them to an array.
House *myCrib = [House house]; House *johnHome = [House house]; House *lisaHome = [House house]; House *whiteHouse = [House house]; NSArray *houses = [NSArray arrayWithObjects: myCrib, johnHome, lisaHome, whiteHouse, nil];
As a rule, all objects of the House have a retention rate of two times, but once they are implemented automatically. After some time, I decided to free myCrib, even if I am not the owner - I was never saved and was not initialized.
myCrib
[myCrib release];
The save count should drop to zero, and my object should be freed. Now my question is: will this illegal action cause my application to work erroneously or even crash or will it NSArrayjust delete my object from its list with bad consequences.
NSArray
I am looking for a way to keep a list of objects, but I want the list to support itself. When some object disappears, I want the link to it to disappear from my array gracefully and automatically. I am thinking of a subclass or wrapper NSArray.
Thank.
myCrib, . . , - . ; , - .
, : , . , , . , .
, ( ):
NSPointerArray
CFMutableArrayRef
retain
release
DDAutozeroingArray
NSMutableArray
: , NSArray .
. , , , , . , , , , . , , , - , , NSArray .
, . - , .
, , / / , . , -retain - , , , , , ; , .
Core Data. , . , to-many - , , .
: , ios. MacOS X, NSPointerArray. , NSPointerArray . , , , .
ios
, . - , . NSArray.
, , , . .
. NSArray - , , , ?
NSArray . , , , , , .
, . - , , , . , .
I created a wrapper class - in my code it was called a controller that supports an (mutable) array for me. I initialize the controller class in my view controllers — the place I need them, instead of using the array directly.
Invalid code for me. :-P