Re: How to fix warning?
Re: How to fix warning?
- Subject: Re: How to fix warning?
- From: Uli Kusterer <email@hidden>
- Date: Thu, 29 Aug 2013 12:59:40 +0200
On Aug 28, 2013, at 10:26 PM, Dave <email@hidden> wrote:
> NSCharacterSet *stopCharacters = [NSCharacterSet characterSetWithCharactersInString:[NSString stringWithFormat:@"< \t\n\r%C%C%C%C", 0x0085, 0x000C, 0x2028, 0x2029]];
Well, the %C expects a unichar (which is defined as another name for an unsigned short), while you are giving it 0x0085, which is a (signed) int. While you can mark a literal as an unsigned int by writing e.g. 0x0085U, there's no way to write a 'short' literal in C. So the best you can do is write the numbers as
NSCharacterSet *stopCharacters = [NSCharacterSet characterSetWithCharactersInString:[NSString stringWithFormat:@"< \t\n\r%C%C%C%C", (unichar)0x0085U, (unichar)0x000CU, (unichar)0x2028U, (unichar)0x2029U]];
I.e. make them unsigned and typecast them to short. Using escape sequences instead as others have suggested is probably the better solution (then you can get rid of the entire -stringWithFormat: call as well and just write the whole string as one literal). This'll work as long as you are using a current version of the llvm compiler, I think. Older versions of the compilers included in Xcode didn't support the Unicode escape sequence as far as I remember.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden