Whats the advantage of using a static NSString for CellIdentifier?
cocoa-touch, ios, objective-c, uitableview
Solution
`cellForRowAtIndexPath:` gets called a lot. Anytime you have a method that is called over and over in a short amount of time you want to minimize the number of objects that are waiting to be auto released, because these objects will be retained on the stack until -- at minimum -- the next run loop. Using a static string ensures that the string object only gets created once, rather than each time the method is called.
It's not strictly necessary, but when you have a limited amount of memory as you do on mobile devices, you want to optimize the number of objects that are created in a short amount of time, where possible.
Problem
I always see boilerplate for `UITableViewController` declare ``` static NSString *CellIdentifier ``` in ``` - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath ``` Why static? I've changed this in a lot of places because my `CellIdentifier` changes based on the section? whats the reasoning behind this being static? Am I affecting performance?