我有下面的代码:为什么系统调用UIApplicationDelegate的dealloc方法?
// create new delegate
MyCustomApplicationDelegate *redelegate = [[MyCustomApplicationDelegate alloc] init];
redelegate.delegate = [(NSObject<UIApplicationDelegate42> *)[UIApplication sharedApplication].delegate retain];
// replace delegate
[UIApplication sharedApplication].delegate = redelegate;
...
[UIApplication sharedApplication].delegate = redelegate.delegate;
[redelegate.delegate release];
最后一行称为基UIApplicationDelegate类的dealloc方法系统后。 那么,为什么?我读到的UIApplication苹果文档,有关委托财产:
@属性(非原子,分配)的ID代表
讨论的代表必须采用UIApplicationDelegate正式 协议。 UIApplication指定并不保留委托。
它清楚地表明,UIApplication指定并不保留委托。那么,为什么它会摧毁我的基地代表?
感谢这个伟大的评论 – 2013-01-11 08:07:51