On Sep 1, 2014, at 5:51, "Dave" <d...@looktowindward.com> wrote:
> 
> I have a method that takes a String and depending on it’s value needs to 
> return an NSTextAlignment type. However, if the string is invalid, then I 
> want to indicate that an error so I pass back -1. This is fine expect I get 
> warnings on this code:
> 
> if (myTextAllignment != -1)
>    theFieldOutlet.textAlignment = myTextAllignment;
> 
> Warning:
> 
> Comparison of constant -1 with expression of type 'NSTextAlignment' (aka 
> 'enum NSTextAlignment') is always true
> 
> What is the best way to fix this?

Just cast it to the type you need.

If(myTextAlignment != (NSTextAlignment)-1)

Steve via iPad
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to