Search code examples
iosobjective-cxcode5

Implicit conversion from enum type 'NSTextAlignment' aka 'enum NSTextAlignment' to diff. enumeration type 'UITextAlignment' aka 'enum UITextAlignment'


I am using Xcode 5.0.2 and getting the following warning when trying to compile my objective C code:

**Implicit conversion from enumeration type 'NSTextAlignment' (aka 'enum NSTextAlignment') to different enumeration type 'UITextAlignment' (aka 'enum UITextAlignment')**  

The Warning is in abcLabel.m:

_**CTTextAlignment alignment = CTTextAlignmentFromUITextAlignment(label.textAlignment);**_

Any help to fix this Warning?


Solution

  • In iOS 6+ UILabel's textAlignment property is of type NSTextAlignment (prior to that it was of type UITextAlignment). If you're compiling for iOS 6 or greater, simply switch to use NSTextAlignmentToCTTextAlignment() instead.