Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check the NSString contains the '%' or not?

I want to ask a question about the objective C. Does the NSString * contains some functions to check the NSString * contains some string in the UITextField.text? For example

NSString *checkString = @"abcd%"

if(checkString contains '%') // I want this function
   return YES;
else
   return NO;
like image 493
Questions Avatar asked Aug 19 '10 06:08

Questions


People also ask

How do I know if NSString is empty?

You can check if [string length] == 0 . This will check if it's a valid but empty string (@"") as well as if it's nil, since calling length on nil will also return 0. There are some very rare NSStrings where this will result in a false negative (saying the string isn't empty, when, for practical purposes, it is).

What is difference between string and NSString in Swift?

The Swift string is one character long, as expected. The NSString says it has a length of seven — this matches with the length of the Swift string's utf16 view, since NSStrings are backed by UTF-16: 09:02 The Swift string's unicodeScalars view returns a count of four.


1 Answers

if([checkString rangeOfString:@"%"].location != NSNotFound)
    // hooray!
like image 65
Noah Witherspoon Avatar answered Sep 23 '22 11:09

Noah Witherspoon