I am new to iPhone Development.
+ (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;
}
Here I am calling that method:
gmGridView = [[GMGridView alloc] init];
gmGridView.layoutStrategy = [GMGridViewLayoutStrategyFactory strategyFromType:GMGridViewLayoutHorizontalPagedLTR];
[self.view addSubview:gmGridView];
Now my question is that how to release strategy object of strategyFromType method?Its giving me potential leak.and if i am going to release/autorelease,my application is crashing.
Please help meThanking you…
UPDATE:
The answer about returning an autoreleased object is correct, the problem is that the
GMGridViewusesARCaccording to the description in the project’s site.So i suppose you need to add it the project as sub module, but you can search a little about instructions…