gpt4 book ai didi

ios - 我试过这段代码,但在 titleForHeaderInSection 中出现错误 "EXC_BAD_ACCESS"

转载 作者:行者123 更新时间:2023-11-29 11:41:15 25 4
gpt4 key购买 nike

我正在使用 MRC(不要使用 ARC)

节.h

@property (nonatomic, assign) NSString* headerTitle;

section.m

- (instancetype)initwhithHeaderTitle:(NSString *)headerTitle {
self.headerTitle = headerTitle;
}
- (void)dealloc {
self.headerTitle = nil;
}

表格 View .m

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return self.sections[section].headerTitle;
}

但滚动时出现错误 BAD ACCESS。帮帮我

最佳答案

你的 headerTitle 是 assignweak 一样,你必须保留它 retain

替换你的代码

@property (nonatomic, assign) NSString* headerTitle;

@property (nonatomic, retain) NSString* headerTitle;

编辑


您需要使用非 ARC。 发布

关于ios - 我试过这段代码,但在 titleForHeaderInSection 中出现错误 "EXC_BAD_ACCESS",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46440276/

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