NSString *str;
// 使用stringWithFormat生成一格式化字符串
str = [NSString stringWithFormat:@"This is %@","John"];
NSLog(@"str--->%@",str);
// 字符串长度length;
NSLog(@"The length of this string is %@",[str length]);
// 字符串比较 isEqualToString, 返回NO(false),isEqualToString区分大小写
BOOL isequal = [str isEqualToString:@"this is John"]; // 字符串序列比列 compare,返回结果NSComparisonResult
// type enum _NSComparisonResult{
// NSOrderedAscending = -1,
// NSOrderedSame,
// NSOrderedDescending
// }
int result = [@"bool" compare:@"cool"];
NSLog(@"The result is %d",result); // compare 比较规则options
// NSLiteralSearch 区分大小写(完全比较)
// NSCaseInsensitiveSearch 不区分大小写
// NSNumericSearch 只比较字符串的个数,而不比较字符串的字面值
int result1 = [@"This is John" compare:@"this is John" options:NSCaseInsensitiveSearch | NSNumericSearch];
NSLog(@"The result is %d",result1); // 字符串开头是否包括另一字符串 hasPrefix,返回结果YES(true)
BOOL isHas = [str hasPrefix:@"This"];
// 字符串结尾是否包括另一字符串 hasSuffix,返回结果YES(true)
BOOL isHas = [str hasSuffix:@"John"]; // 查找字符串在另一字符串中的位置
NSRange range = [str rangeOfString:@"is" options:NSCaseInsensitiveSearch];
NSLog(@"The location in the string named 'str' of 'is' is @d",range.location);

最新文章

  1. 技术笔记:XMPP之openfire+spark+smack
  2. ASP.NET MVC自定义验证Authorize Attribute
  3. Android 简易崩溃日志保存
  4. css基本设置
  5. PMBOK学习笔记一
  6. 【转】让Bootstrap 3兼容IE8浏览器
  7. 《OpenGL游戏编程》第9章-PlanarShadow关键代码注释
  8. Redis 安装 启动 连接 配置 重启
  9. [翻译]了解ASP.NET底层架构(八)
  10. Windows下IIS以FastCGI模式运行PHP
  11. poj1849
  12. leetcode Climbing Stairs python
  13. 编写JQuery插件-2
  14. iOS进阶之如何进行 HTTP Mock(转载)
  15. Temporary failure in name resolutionf的解决方法
  16. systemctl启动tomcat后,jps看不到进程
  17. 傻瓜式搭建私人网络硬盘——owncloud安装指南
  18. 基于Python37配置图片文字识别
  19. 2019.02.17 spoj Query on a tree V(链分治)
  20. 【逆向工具】IDA使用6-签名文件制作

热门文章

  1. 【BZOJ4671】(斯特林反演)
  2. Ubuntu gcc错误:对'log'等函数未定义的引用
  3. UIScrollView监听静止的数种情况
  4. web页面如何打包封闭成手机APP
  5. 智能DNS
  6. Spring boot 与mybatis 多数据源问题
  7. RabbitMQ 简单了解以及使用
  8. Pandas描述性统计
  9. scala学习手记16 – scala中的static
  10. 图片加载之Picasso使用