2
我想提取NSarray的所有「女兒」。ios如何提取for循環中的數組的所有rangeOfString?
例如,NSArray中作出這樣的:
hello
hi
hello daughter
my goodness
daughter (someone)
my daughter
how are you?
etc.
而且我想提取包含「女兒」的所有行。你能指出我正確的方向嗎?
我當前的代碼是:
for (NSString *mystring in self.array)
{
if ([mystring rangeOfString:searchText].location!=NSNotFound)
{
NSUInteger idx = [self.array indexOfObject:mystring];
[self.filterarray addObject: mystring];
}
}
什麼是最低ios? – wagashi
自從iOS 4.0以來,自3.0 iOS和predicateWithBlock:開始存在'filteredArrayUsingPredicate:'。 – Regexident
self.filterarray是一個nsmutablearray,如何使用代碼添加對象到它?我寫了'\t self_filterarray = [self.array filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^ BOOL(id string,NSDictionary * bindings){\t return([string rangeOfString:searchText] .location!= NSNotFound); \t}]];'warnings:incompatible Objective-C types'struct NSArray *',expected'struct NSMutableArray *',當傳遞參數1的'setFilteredListContent:'從不同的Objective-C類型 – wagashi