Using NSPredicate to determine if a string equals another string

前端 未结 2 954
一整个雨季
一整个雨季 2020-12-16 10:11

I have an NSArray of CalEvents returned with the [CalCalendarStore eventPredicateWithStartDate] method. From the events returned, I am trying to ke

相关标签:
2条回答
  • 2020-12-16 10:28

    Try predicate with format @"self.title like[c] 'on call'". The following sample code outputs 2 strings:

    NSArray* ar = [NSArray arrayWithObjects:@"on call", @"I'm on call", @"lala", @"On call", nil];
    NSArray* filt = [ar filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self like[c] 'on call'"]];
    NSLog([filt description]);
    
    //Output
    "on call",
    "On call"
    
    0 讨论(0)
  • 2020-12-16 10:46

    Try [NSPredicate predicateWithFormat:@"title ==[c] 'on call'"];

    (The [c] makes the equality comparison case-insensitive.)

    0 讨论(0)
提交回复
热议问题