gpt4 book ai didi

ios - 适用于 iOS 7 的 localizedCaseInsensitiveContainsString

转载 作者:行者123 更新时间:2023-11-29 12:17:24 24 4
gpt4 key购买 nike

我如何为 iOS 7 使用 localizedCaseInsensitiveContainsString

因为 ragneOfString 方法没有给我预期的结果。但是 localizedCaseInsensitiveContainsString 方法给了我想要的结果。

并且 localizedCaseInsensitiveContainsString 在 iOS7 中不可用。我试过了,但它没有给我想要的结果

 if([session.sessiontitle rangeOfString:searchtext options:NSCaseInsensitiveSearch].location!=NSNotFound 
|| [session.roomname rangeOfString:searchtext options:NSCaseInsensitiveSearch].location!=NSNotFound
|| [session.speakername rangeOfString:searchtext options:NSCaseInsensitiveSearch].location!=NSNotFound
|| [session.speakerprofile rangeOfString:searchtext options:NSCaseInsensitiveSearch].location!=NSNotFound)
{
[sessionArray addObject:session];
}

提前致谢!

最佳答案

您需要使用本地化方法。

[session.sessiontitle rangeOfString:searchtext options: NSCaseInsensitiveSearch range:NSMakeRange(0, session.sessiontitle.length) locale:[NSLocale currentLocale]].location!=NSNotFound

更新:
这有效:
NSArray *allNames=@[@"does jenny work",@"JENNy works",@"works with JEnny",@"jack",@"ram",@"jhon"];
NSMutableArray *results=[NSMutableArray new];
for (NSString *name in allNames) {
if ([name rangeOfString:@"jenny" options:NSCaseInsensitiveSearch range:NSMakeRange(0, name.length) locale:[NSLocale currentLocale]].location!=NSNotFound) {
[results addObject:name];
}
}
NSLog(@"results :>%@<",results);<br/>
results :>(
"does jenny work",
"JENNy works",
"works with JEnny"
)<

关于ios - 适用于 iOS 7 的 localizedCaseInsensitiveContainsString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31650252/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com