قالب وردپرس درنا توس
Home / IOS Development / ios – set delegate for WCSession to zero

ios – set delegate for WCSession to zero



I use & # 39; WCSession & # 39; for the connection between my app and apple watch. I preferred the singleton approach. So I've shared a session:

  static Shared_WCSession * sharedInstance = nil;
+ (Shared_WCSession *) getSharedInstance {
@sync (self) {
// If the class variable containing the reference to the individual ContentManager object is empty, create it.
if (sharedInstance == null) {
sharedInstance = [[Shared_WCSession alloc] init];
}
}
return sharedInstance;
}

Then during the start session, I set up the delegate for the session:

  - (invalid) startSession {
if ([WCSession isSupported]) {
self.session = [WCSession defaultSession];
self.session.delegate = self;
[self.session activateSession];
LOGG (@ "WCSession is supported");
}
}

What is the correct way to redistribute the delegate?

According to Apple's documents, I can do it by the following methods:

  sessionDidBecomeInactive (_ :)
sessionDidDeactivate (_ :)

If I set the delegate to zero, will it interfere with the execution of my applications?


Source link