我坚持可可内存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