8

I need to test for the availability of blocks at runtime, so I can handle backwards compatibility with iOS 3. Any tips?

edit: So far I'm doing if (!NSClassFromString(@"NSBlockOperation")) {...} Seems to be working...

Kenny Winker
  • 11,919
  • 7
  • 56
  • 78

1 Answers1

7

You will also need to make sure to weak link the libSystem.B.dylib, set your base SDK to 4.0 and deployment target to 3.1.3, as described here.

A good overview on how to deal with iOS versioning issues can also be found in this this Cocoa with Love article: Tips & Tricks for conditional iOS3, iOS3.2 and iOS4 code

Community
  • 1
  • 1
martineno
  • 2,623
  • 17
  • 14
  • I assume weakly linking libSystem.B.dylib lets me use NSBlockOperation instead of doing NSClassFromString every time. Oh for it to be a year from now, when I'll safely be able to drop support for iOS 3. – Kenny Winker Nov 20 '10 at 10:15
  • @Kenny I believe so. Also check out the Tips & Tricks link. It has a few different approaches to having various versions of SDK coexist within your app. – martineno Nov 20 '10 at 10:29