how to detect is NSMutableAttributedString attribute NSStrikethroughStyleAttributeName available to use?

StackOverflow https://stackoverflow.com/questions/18254393

문제

I mean detect is i'm able to use attribute NSStrikethroughStyleAttributeName ofNSMutableAttributedString like:

if ([object responseToSelector:@selector(someSelector)])

or like:

if ([SomeNewClass class])

i don't wan't compare system version, but i wan't check exactly this item;

도움이 되었습니까?

해결책

NSStrikethroughStyleAttributeName is available from iOS 6 so if you are supporting 6 and above you have no worries.

Apple also uses weak linking. This sets symbols that aren't available in the current version of the OS to NULL. So, you can test the symbol to see if it exists with:

if (NSStrikethroughStyleAttributeName != nil) {
    // use NSStrikethroughStyleAttributeName
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top