我正在開發一個AppleWatch應用程序。在開發IOS應用程序min版本IOS 6.0之前。我正在使用WatchOS 2.0開發AppleWatch應用程序。 IOS應用程序類下的類代碼。 WatchConnectivity框架和WCSessionDelegate協議需要min IOS版本9.0。那麼,如何運行老版本沒有崩潰IOS協議和框架最低IOS版本檢查
.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 the base class */
/* then initialize the 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
}
/* finally return the object */
return self;
}
@end
更新我的問題你是怎麼說的。但我不能調試.m文件代碼 – hiwordls