apple watch - IOS protocol and framework minimum IOS version check -


i developing applewatch application. before developed ios application min version ios 6.0. applewatch application i'm developing watchos 2.0. below class code in ios application class. watchconnectivity framework , wcsessiondelegate protocol need min ios version 9.0. how run old version without crash

.h #import <foundation/foundation.h> #if __iphone_os_version_min_required >= __iphone_9_0 #import <watchconnectivity/watchconnectivity.h> #endif  #if __iphone_os_version_min_required >= __iphone_9_0 @interface watchconnectivitymanager : nsobject<wcsessiondelegate>{ #else @interface watchconnectivitymanager : nsobject{ #endif  }  @property(nonatomic, assign) bool onetimesaved;  +(watchconnectivitymanager*)getinstance;  -(void)shareddefaultsdatasave:(nsstring*)params; @end   .m #import "watchconnectivitymanager.h"  @implementation watchconnectivitymanager @synthesize onetimesaved;  static watchconnectivitymanager *instance =nil;   - (id) init {     /* first initialize base class */      /* initialize instance variables */     if (self = [super init]) {         #if __iphone_os_version_min_required > __iphone_9_0         if (system_version_greater_than_or_equal_to(@"9.0") && nsclassfromstring(@"wcsession")!=nil && [wcsession issupported]) {             wcsession *session = [wcsession defaultsession];             session.delegate = self;             [session activatesession];         }         #endif      }     /* return object */      return self; } @end 

#if __iphone_os_version_min_required > __iphone_9_0     // after iphone os sdk 9.0 #else     // before iphone os sdk 9.0 #endif 

you can't use watchconnectivity framework , wcsessiondelegate protocol before ios9.0.so same thing using lower apis or nothing.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -