我堅持可可內存Managagment。RetainCount內存
- (IBAction) createPush:(UIButton *)sender {
[create setEnabled:NO];
[release setEnabled:YES];
aLocation = [[Location alloc] init];
// Put some Example Stuff in the Class
aLocation.title = @"Apartment";
aLocation.street = @"Examplestreet 23";
aLocation.zip = @"12345";
aLocation.city = @"Exampletown";
aLocation.http = @"http://google.com";
aLocation.info = @"First Info Text";
aLocation.info2 = @"Second Info Text, not short as the first one";
aLocation.logoPath = @"http://google.de/nopic.jpg";
[aLocation.pictures addObject:@"http://google.de/nopic.jpg"];
[aLocation.pictures addObject:@"http://google.de/nopic.jpg"];
}
- (IBAction) releasePush:(UIButton *)sender {
[release setEnabled:NO];
[create setEnabled:YES];
[aLocation release];
aLocation = nil;
}
此代碼工作正常,如果我設置或獲取變量,但是當我稱之爲「最後」的釋放(所以保留計數爲0),它的dealloc aLocation的方法被調用,但在儀器分配你看,沒有回憶。
這裏位置的來源:
http://homes.dnsalias.com/sof/Location.m 同一鏈路上與「.H」而不是「.M」爲頭文件(很抱歉,因爲Spaming規則的)。
而且整個項目:http://homes.dnsalias.com/sof/Location.zip
感謝您的幫助,哪裏是我的失敗?丹尼斯
這是執行'aLocation'的所有代碼嗎?它不會被放入數組中,例如? – 2011-05-04 18:59:01
是的,這是所有!如果你想仔細觀察下載源代碼。 – 2011-05-04 19:53:30