gpt4 book ai didi

iphone - 无法设置文本标签单元格

转载 作者:行者123 更新时间:2023-11-29 05:05:28 26 4
gpt4 key购买 nike

这是我的代码

@property (nonatomic,retain) NSMutableArray *category;

@synthesize category;

NSString * path = [[NSBundle mainBundle] pathForResource:@"categorylist" ofType:@"txt"];
NSString * content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL];
self.category = [NSMutableArray arrayWithArray:[content componentsSeparatedByString:@"\n"]];
[content release];

这里有错误

cell.textLabel.text = [category objectAtIndex:[indexPath row]];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;

我是新手。所以请帮我找出解决方案。

vvv来自许多帮助这是最终确定解决方案代码。

@property (nonatomic,retain) NSMutableArray *category;

@synthesize category;

NSString * path = [[NSBundle mainBundle] pathForResource:@"categorylist" ofType:@"txt"];
NSString * content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL];
self.category = [NSMutableArray arrayWithArray:[content componentsSeparatedByString:@"\n"]];

这里

cell.textLabel.text = [NSString stringWithFormat:@"%@",[self.category objectAtIndex:indexPath.row]];

最佳答案

不要发布内容。如果您没有使用allocnewretaincopy,则不允许释放。

您应该阅读 Memory Management Programming Guide再次

关于iphone - 无法设置文本标签单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5522242/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com