Hier ist mein Test zum Filtern des Arrays durch eine Zeichenfolge. Es funktioniert gut, wenn meine Zeichenfolge nicht enthält (') ZeichenNSPredate zum Filtern von Array mit (') Zeichen Problem
NSMutableArray *array = [NSMutableArray arrayWithObjects:@"Nick", @"b'en", @"Adam", @"Melissa", @"arbind", nil];
//NSPredicate *sPredicate = [NSPredicate predicateWithFormat:@"SELF contains[c] 'b'"]; -> it work
NSPredicate *sPredicate = [NSPredicate predicateWithFormat:@"SELF contains[c] 'b''"]; -> it crash
NSArray *beginWithB = [array filteredArrayUsingPredicate:sPredicate];
NSLog(@"beginwithB = %@",beginWithB);
Ich versuche auch, meine Zeichenfolge 'b\''
oder 'b'''
aber noch
Hier Absturz zu ändern, ist das Crash-Protokoll
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "SELF contains[c] 'b'''"'
Wie löst man es? Jede Hilfe wäre sehr geschätzt.
Vielleicht helfen, aber 'contains' klingt wie ein schlechter Kandidat für ein Prädikat, dessen Ergebnisse genannt werden' beginWith ... ' – Alladinian
@Alladinian ja, es ist nur mein Test, ich kopiere diesen Code nur von http://Stackoverflow.com/a/25738783/5381331. Danke für Sie Korrektur –