일반적으로 Extension 대리자의 메서드를 다른 IntefaceController에서 호출 할 수 있습니까?Extension 대리인의 메소드 호출
뭔가 같은 :
InterfaceController *interfaceController =[[InterfaceController alloc] init];
interfaceController callMethod
내 인터페이스 컨트롤러
#import "InterfaceController.h"
#import "OrdinaryEventRow.h"
#import <UIKit/UIKit.h>
#import <WatchConnectivity/WatchConnectivity.h>
@interface InterfaceController()
@implementation InterfaceController
- (void)awakeWithContext:(id)context {
[super awakeWithContext:context];
//Configure interface objects here.
-(void)doSomething {
[self presentControllerWithName:@"goalView" context:nil];
}
@end
ExtensionDelegate :
#import "ExtensionDelegate.h"
#import "InterfaceController.h"
#import <WatchConnectivity/WatchConnectivity.h>
#import "setGoal.h"
@implementation ExtensionDelegate
//Handle Local Notification Actions
-(void)handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UNNotification *)localNotification{
if([identifier isEqualToString:@"action"]){
//Setup WCSession
if ([WCSession isSupported]) {
[[WCSession defaultSession] setDelegate:self];
[[WCSession defaultSession] activateSession];
//Get the value from slider
NSString *someString = [[NSUserDefaults standardUserDefaults]
stringForKey:@"Update"];
NSString *Update = @"Update";
NSDictionary *applicationData = [[NSDictionary alloc] initWithObjects:@[Update] forKeys:@[@"Update"]];
//Send Message to the iPhone (handle over the goal value)
[[WCSession defaultSession] sendMessage:applicationData
replyHandler:^(NSDictionary *reply) {
//handle reply from iPhone app here
}
errorHandler:^(NSError *error) {
//catch any errors here
}
];
}
}
//If Goal Setting was clicked
if([identifier isEqualToString:@"action3"]){
//here I want to call doSomething from InterfaceController
}
}
그래서 난 그냥 ExtensionDelegate에서 InterfaceController에 정의 된 메소드를 호출합니다.
다른 컨트롤러에서 대리인에 구현 된 사용자 지정 함수를 호출 하시겠습니까? –
글쎄, 내 InterfaceController에 - (void) doSomething과 같은 메소드가있다. ExtensionDelegate 클래스에서이 메서드를 호출하려고합니다. –
당신은 ExtensionDelegate 클래스와 interfaceController 코드를 공유 할 수 있습니까? –