tobihagemann / THLabel

UILabel subclass, which additionally allows shadow blur, inner shadow, stroke text and fill gradient.
https://tobiha.de
Other
665 stars 111 forks source link

Warning in XCode 7 #33

Closed margusholland closed 8 years ago

margusholland commented 8 years ago

THLabel.m line 430:

CTTextAlignment alignment = NSTextAlignmentToCTTextAlignment ? NSTextAlignmentToCTTextAlignment(self.textAlignment) : [self CTTextAlignmentFromNSTextAlignment:self.textAlignment];

gives a warning "Code will never be executed".

Not really a problem, but I like to keep my code warning free, so might be worth fixing for people with similar needs.

tobihagemann commented 8 years ago

Not sure which warning flags you have set on your project, but that's absolutely right, if you target iOS 6.0 or higher. That code is just a workaround for iOS versions lower than 6.0. I guess it should be solvable with a __IPHONE_OS_VERSION_MIN_REQUIRED. Could you try this out, before I push an update?

#if defined(__IPHONE_6_0) && (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0)
    CTTextAlignment alignment = NSTextAlignmentToCTTextAlignment(self.textAlignment);
#else
    CTTextAlignment alignment = NSTextAlignmentToCTTextAlignment ? NSTextAlignmentToCTTextAlignment(self.textAlignment) : [self CTTextAlignmentFromNSTextAlignment:self.textAlignment];
#endif
margusholland commented 8 years ago

Yep, works fine with that new code snippet and the warning goes away. I’m not using any other warning flags that come with the default settings of XCode.

tobihagemann commented 8 years ago

Fixed in version 1.4.7