Thing *thingA = [[Thing alloc] init];
thingA.name = @"paper";
Thing *things[0];
things[0] = thingA;
NSLog(@"%@", things[0].name);
// output paper
[thingA release];
// here dealloc on Thing class is call
NSLog(@"%@", things[0].name);
// output paper yet
- Here I thought that this object would be nill
爲什麼元件東西[0]指向thingA指針不是nil,從而使應用程序崩潰?爲什麼thingA指針不是零?
你爲什麼這樣做?據我所知,在'thingA'發佈之後,不能保證'things [0]'將存在,因爲'thingA'將很快被釋放。 – 2011-02-25 00:36:35
[Objective-C中的C數組維護指向已經釋放對象的指針]的可能重複(http://stackoverflow.com/questions/5124715/c-array-in-objective-c-maintains-pointer-to-object-already -deallocated) – icktoofay 2013-11-14 04:43:51