3

在我的代码@property中,我在我的子类中为我的 Main 类声明一个以在那里设置值

@property(nonatomic,retain)  MainViewController *father;

但我注意到在我的主类中没有调用retaindealloc方法,但是当我将其更改为:

@property(strong, nonatomic)  BabyViewController *father;

dealloc返回要调用的方法。

我这样做了,但不知道这是否会影响我的代码性能。

我在我的主要课程中使用它property来做到这一点:

    subClass* controller = [[subClass alloc] initWithPageNumber:page];
    controller.father=self;
    [controller.view removeFromSuperview];

这是我能做的最好的吗??

4

1 回答 1

3

更好的是,您可以使用assign属性来声明viewControllersand 。delegates它将分配数据而不是dealloc变量。所以像这样使用,

@property(nonatomic,assign)  MainViewController *father;
于 2013-04-30T08:25:43.910 回答