我是 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 方法的策略对象?它给了我潜在的泄漏。如果我要释放/自动释放,我的应用程序正在崩溃。请帮帮我谢谢...