Why does this sometimes crash
Inside the function
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
I create an NSString, then give cell.textLabel.text the value of this string. Then I release it. The program will crash on getting one of the fields at the end.
If I don't release the NSString, then the program doesn't crash. But won't this crea开发者_运维知识库te a memory leak?
How are you creating the NSString? If it's anything other than an alloc followed by an init, you don't need to release it!
精彩评论