I have a method that scans a string, converting any new lines to <br> for HTML. The line in question is:
NSCharacterSet *newLineCharacters = [NSCharacterSet characterSetWithCharactersInString:
[NSString stringWithFormat:@"\n\r%C%C%C%C", 0x0085, 0x000C, 0x2028, 0x2029]];
Xcode gives me a warning here:
Format specifies type 'unsigned short' but the argument has type 'int'
It’s recommending that I change all %C to %d, however that turns out to break the function. What is the correct way to do this, and why is Xcode recommending the wrong thing?
One option is to cast your arguments to unsigned short: i.e.
(unsigned short)0x0085etcBut if you’re looking for newlines, you should just use the newline character set. This is “Unicode compliant”:
[ NSCharacterSet newlineCharacterSet ]edit
Revisiting this question: If you are trying to separate an NSString/CFString by line breaks, you should probably use
-[ NSString getLineStart:end:contentsEnd:forRange:].