アイテム用のNSMutableArray
withNSStrings
があります。一部は空白です。@ ""などと比較して、ループに頼ることなく空白を見つけて削除する最も簡単な方法は何ですか。
ありがとう、
ダグ
アイテム用のNSMutableArray
withNSStrings
があります。一部は空白です。@ ""などと比較して、ループに頼ることなく空白を見つけて削除する最も簡単な方法は何ですか。
ありがとう、
ダグ
NSMutableArray *test = [[NSMutableArray alloc]initWithObjects:@"",@"",@"test",@"test1", nil];
[test removeObject:@""];
これを行うには、 NSPredicateを使用できます。
NSArray *myFilteredArray = [yourArray filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"length > 0"]];
[a filterUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
[evaluatedObject length] != 0;
}]];