drawInRect:withAttributes: in iOS 7 and iOS 6.1

iOS 7 comes with a new method in NSString for drawing text:


However if you try to test and use the API using:

if ([string respondsToSelector: @selector(drawInRect:withAttributes:)])

You thing it should work, but actually it will crash on iOS 6.1. It is because the method was already existed in iOS 6.1 as hidden API. And it seems the parameters are different and so the call will crash. To test if we can use the API, I test availability of another method:

if ([string respondsToSelector: @selector(drawWithRect:options:attributes:context:)])