Search code examples
iphonenscharacterset

'NSCharacterSet' may not respond to '-count'


I got a warning message in

NSCharacterSet *myCharSet3 = [NSCharacterSet characterSetWithCharactersInString:query3]; 
int chr_count3;
chr_count3=[myCharSet3 count];

How to fix that warning ?


Solution

  • NSCharacterSet does not officially provide a count method. However in my testing, [myCharSet3 count] actually gives the correct result. So just to get rid of the warning:

    chr_count3 = (int)[myCharSet3 performSelector:@selector(count)];
    

    But I don't think it's a good idea.