iphone - 如何检查 NSString 是否包含 '%'?

标签 iphone objective-c nsstring

我想问一个关于 Objective-C 的问题。NSString * 是否包含一些函数来检查 NSString * 是否包含 UITextField.text 中的一些字符串?例如

NSString *checkString = @"abcd%"

if(checkString contains '%') // I want this function
   return YES;
else
   return NO;

最佳答案

if([checkString rangeOfString:@"%"].location != NSNotFound)
    // hooray!

关于iphone - 如何检查 NSString 是否包含 '%'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3519387/

相关文章:

objective-c - 通过警报确认删除 UITableViewController 中的一行

objective-c - 将 NSString 转换为 UIColor

iphone - 如何计算NSString对象中非字母数字字符的数量?

iphone - IOS 中是否存在用于 UI 控件自动化的现有库

iphone - self.view.backgroundColor = [UIColor greenColor];在推送 View 中不起作用

ios - Xcode 7.3 : NSArray print custom objects as "" why?

ios - 检测 UIPanGestureRecognizer 开始和结束的 UIView 网格方 block

iphone - 创建新版本应用程序时sqlite文件的更改

iphone - 如何锁定设备上的更改方向?

ios - 获取使用 drawInRect 绘制的 NSString 中 x、y 位置的字符索引