node ninja
node ninja

Reputation: 32986

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 create a memory leak?

Upvotes: 0

Views: 68

Answers (1)

ennuikiller
ennuikiller

Reputation: 46965

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!

Upvotes: 1

Related Questions