Search code examples
iphoneretainautoreleaseuitableview

Retain count for tableView:cellForRowAtIndexPath:


In Apple's example code, the method tableView:cellForRowAtIndexPath: of a UITableViewDataSource returns a cell with a retain count of 1; it allocs it, but doesn't autorelease it. However, the static analyzer complains that this violates the Cocoa naming conventions, since the method name doesn't start with 'new', etc. The documentation doesn't mention the expected retain count of the cell. What retain count should the cell have? Should I file a bug against the documentation? Thanks.

EDIT: The example code I looked at does autorelease it, and my eye somehow skipped over it. Sorry to waste your time. Thanks for the responses.

Further edit: A bug should probably be filed against Clang if questioners are going to get jumped for using its terminology in a question. :-)


Solution

  • The value of retainCount is not really important (it can go up and down for seemingly unknown reasons). But cells created in tableView:cellForRowAtIndexPath: should be autoreleased. What example code are you looking at?