Ios is case-insensitive and ios is case-insensitive.

Source: Internet
Author: User

Ios is case-insensitive and ios is case-insensitive.

  1. NSString * str;
  2. // Use stringWithFormat to generate a formatted string
  3. Str = [NSString stringWithFormat: @ "This is % @", "John"];
  4. NSLog (@ "str ---> % @", str );
  5. // String length;
  6. NSLog (@ "The length of this string is % @", [str length]);
  7. // When the string is compared with isbench tostring, NO (false) is returned, and isbench tostring is case sensitive.
  8. BOOL isequal = [str isw.tostring: @ "this is John"];
  9. // String sequence comparison column compare, and the returned result is NSComparisonResult
  10. // Type enum _ NSComparisonResult {
  11. // NSOrderedAscending =-1,
  12. // NSOrderedSame,
  13. // NSOrderedDescending
  14. //}
  15. Int result = [@ "bool" compare: @ "cool"];
  16. NSLog (@ "The result is % d", result );
  17. // Compare comparison Rules options
  18. // NSLiteralSearch case sensitive (full comparison)
  19. // NSCaseInsensitiveSearch is case insensitive
  20. // NSNumericSearch only compares the number of strings, not the String Literal Value
  21. Int result1 = [@ "This is John" compare: @ "this is John" options: NSCaseInsensitiveSearch | NSNumericSearch];
  22. NSLog (@ "The result is % d", result1 );
  23. // Whether the start of the string contains another string hasPrefix. The returned result is YES (true)
  24. BOOL isHas = [str hasPrefix: @ "This"];
  25. // Whether the end of the string contains another string hasSuffix. The returned result is YES (true)
  26. BOOL isHas = [str hasSuffix: @ "John"];
  27. // Find the position of the string in another string
  28. Nsange range = [str rangeOfString: @ "is" options: NSCaseInsensitiveSearch];
  29. NSLog (@ "The location in the string named 'str' of 'is' @ d", range. location );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.