検索キーワードを導入し、実行時にフィルタリングして、オブジェクトの配列をフィルタリングする必要があります。どうすればいいですか?
//this is my Article class
@property int intID;
@property (nonatomic, strong) NSString *strName;
@property (nonatomic, strong) NSString *strTitle;
@property (nonatomic, strong) NSString *strDescription;
@property (nonatomic, strong) NSString *lang;
@property (nonatomic, strong) NSString *dateDate;
@property (nonatomic, strong) NSData *dataPicture;
@property (nonatomic, strong) NSString *link;
@property (nonatomic, strong) NSString *gallery;
@property int flag;
@property int subcat;
@property int cat;
@property int idpic;
導入された文字列を含むテキストを含む記事を選択する必要があります
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"strName MATCHES '.*(%@).*'", searchText];
NSLog(@"%@", [NSString stringWithFormat:@"strName MATCHES '.*%@.*' OR strTitle MATCHES '.*%@.*'", searchText, searchText]);
articleSearchArray=[NSMutableArray array];
articleSearchArray = [NSMutableArray arrayWithArray:[allArticleArr filteredArrayUsingPredicate:predicate]];
for(Article *article in articleSearchArray)
{
NSLog(@"Article id is %i", article.intID);
}
[mytableView reloadData];
}