gpt4 book ai didi

iOS - 对象未添加到数组

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

我不明白为什么附件没有添加到数组filteredAttachmentsdataAttachment 是有附件的那个,我想在其中搜索附件有一个特定的名称,然后将匹配的名称添加到

.h:

@property (nonatomic, strong) NSMutableArray * dataAttachments;

@property (nonatomic, strong) NSMutableArray * filteredAttachments;

.m:

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {

self.filteredAttachments = [NSMutableArray new];

[self.dataAttachments enumerateObjectsUsingBlock:^(Attachment *attachment, NSUInteger index, BOOL *stop) {

if ([attachment.name containsString:self.searchBarFiltern.text]) {

[self.filteredAttachments addObject:attachment];

}
}];

[self.tableView reloadData];
}

最佳答案

首先初始化你的 self.dataAttachments 数组

self.dataAttachments = [NSMutableArray array]:

然后检查 self.dataAttachments 数组的输出是空白还是填充。

关于iOS - 对象未添加到数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30322968/

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