gpt4 book ai didi

ios - 从文件中搜索 NSString

转载 作者:行者123 更新时间:2023-11-28 23:13:49 25 4
gpt4 key购买 nike

是否可以创建一个函数来搜索字符串中的精确子字符串,以便仅在找到精确字符串时才“返回 true”,而不是作为更大单词的一部分?

NSString* search = @"tele";
NSString* stringOne = @"telephone";
NSString* stringTwo = @"tele phone";
NSString* stringThree = @"phone tele";

我的意思是:是否可以通过在字符串 2 和 3 而不是 1 中找到 NSString“搜索”的方式来搜索字符串?

最佳答案

尝试在 NSString 类中使用以下函数:

- (NSRange)rangeOfString:(NSString *)aString

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsstring_Class/Reference/NSString.html

关于ios - 从文件中搜索 NSString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7289873/

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