在Watchkit上调用方法 [英] Calling a Method on Watchkit

查看:123
本文介绍了在Watchkit上调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我昨天参加了一个监视程序黑客马拉松,在使用NSMap类调用使用Google Maps API并发送本地通知的方法时遇到了一些问题.如果我从Watchkit扩展中调用此方法,则代码不会编译,但是例如,如果我是从ViewController调用,则一切运行正常

I attended to a watchkit hackathon yesterday and I had some problems regarding calling a method on an NSObject class which uses the Google Maps API and send local notifications. If I call this method from my Watchkit extension, the code doesn't compile, but If I call from the ViewController, for example, everything works perfectly

#import "InterfaceController.h"
#import "Methods.h"

@interface InterfaceController()

 @end


 @implementation InterfaceController

- (instancetype)initWithContext:(id)context {
self = [super initWithContext:context];
if (self){
    // Initialize variables here.
    // Configure interface objects here.
    NSLog(@"%@ initWithContext", self);

}
return self;
}
- (IBAction)butRoute
{
     Methods *mt = [[Methods alloc]init];
    [mt notif:@"ARRIVING!"];
    //***** If I call this method, my code won't compile!!! *****

}

- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
NSLog(@"%@ will activate", self);
}

- (void)didDeactivate {
// This method is called when watch view controller is no longer visible
NSLog(@"%@ did deactivate", self);
}

@end

我得到的错误是:

推荐答案

检查方法"类的目标,并确保它在监视工具扩展目标中.

Check the target for your Methods class and make sure it is in your watch kit extensions target.

或者,查看为共享类构建框架. https://developer.apple.com/videos/wwdc/2014/?id = 416

Alternately, look at building a framework for your shared classes. https://developer.apple.com/videos/wwdc/2014/?id=416

这篇关于在Watchkit上调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆