What will happen if the autorelease is removed from cell creation in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
STVCell *cell = (STVCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[STVCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
}
It will lead to a memory leak.
Because you call
alloc, you are responsible for also callingrelease(or in this caseautorelease).The UITableView will automatically retain the cell and release its use of the cell at the appropriate time, but unless your code also releases the reference that it holds, the cell can never be deallocated.