我是iPhone開發新手。如何釋放它?
+ (id<GMGridViewLayoutStrategy>)strategyFromType:(GMGridViewLayoutStrategyType)type
{
id<GMGridViewLayoutStrategy> strategy = nil;
switch (type) {
case GMGridViewLayoutVertical:
strategy = [[GMGridViewLayoutVerticalStrategy alloc] init];
break;
case GMGridViewLayoutHorizontal:
strategy = [[GMGridViewLayoutHorizontalStrategy alloc] init];
break;
case GMGridViewLayoutHorizontalPagedLTR:
strategy = [[GMGridViewLayoutHorizontalPagedLTRStrategy alloc] init];
break;
case GMGridViewLayoutHorizontalPagedTTB:
strategy = [[GMGridViewLayoutHorizontalPagedTTBStrategy alloc] init];
break;
}
return strategy;
}
在這裏,我調用一個方法:
gmGridView = [[GMGridView alloc] init];
gmGridView.layoutStrategy = [GMGridViewLayoutStrategyFactory strategyFromType:GMGridViewLayoutHorizontalPagedLTR];
[self.view addSubview:gmGridView];
現在我的問題是,如何釋放strategyFromType方法的戰略目標它給了我潛在的leak.and如果我打算髮布/自動釋放,我的應用程序崩潰了。 請幫助meThanking你...
offtopic:你可以簡單地縮短[YourClass頁頭] INIT]到[YouClass新] – CarlJ