0

I'm currently writing an app that uses Facebook integration built into iOS 6. Now in order to do that, I need to

#import <Social/Social.h>

How do I ensure that the device can actually run the code and won't crash (check if it's iOS 6 or iOS 5.1 and then performing the right code, because I support iOS 5.1<= )?

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
Lior Pollak
  • 3,362
  • 5
  • 27
  • 48

2 Answers2

4

You could use:

[[UIDevice currentDevice] systemVersion]
CSolanaM
  • 3,138
  • 1
  • 20
  • 21
  • @harrym17 Use that for the actually implementation, then in your project summary tab change the social framework from required to optional. – Mick MacCallum Oct 03 '12 at 17:59
3

This works fine for me:

if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")){
//Use social framework
}else{
//other option
}
  • Oh thank you! This should work better than the marked answer, I will confirm and mark – Lior Pollak Feb 04 '13 at 18:08
  • 2
    Won't work unless you define it somewhere: http://stackoverflow.com/questions/7848766/how-can-we-programmatically-detect-which-ios-version-is-device-running-on – Ngoan Nguyen Feb 06 '13 at 21:25