Apple-Watch开发1
Communicating between the iOS app and the Watch Extension
There are four scenarios where an app and an extension might wish to communicate:
- Watch extension to suspended/terminated iOS app - use +[WKInterfaceDevice openParentApplication:reply:] if you need to "wake up" your iOS app. If you simply need to leave data in a place for your iOS app to find it later, then you should write it into the shared group container and have your iOS app consult it when it next needs the information.
- Watch extension to running iOS app - use either +[WKInterfaceDevice openParentApplication:reply:] or the Darwin notification center.
- iOS app to suspended/terminated Watch extension - Since the Watch extension is only launched in reaction to your Watch app being launched on the Apple Watch, an iOS app cannot launch its corresponding Watch extension. Instead, the app should write whatever data it wants to send to the Watch extension into the shared group container, and the extension should consult it when it next needs the information.
- iOS app to to running Watch extension - If your iOS app received the -[<UIApplicationDelegate> application:handleWatchKitExtensionRequest:reply:] message, it should use the system-provided reply block to convey information back to the extension. Otherwise you may use the Darwin notification center to pass information back to the extension.
More information on the Darwin notification center can be found in the Documentation.
watchos2 录音功能实现
[self presentAudioRecordingControllerWithOutputURL:fileUrl
preset:WKAudioRecordingPresetWideBandSpeech
maximumDuration:5.0
actionTitle:@"Some Title"
completion:^(BOOL didSave, NSError * __nullable error) {
NSLog(@"didSave:%d, error:%@", didSave, error);
}];
The extension is not automatically notified of changes to the shared user defaults made by the iOS app, and vice versa. If you would like to be notified, you can do so manually by using the Darwin notification center.
auto engine = LuaEngine::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(engine);
lua_State* L = engine->getLuaStack()->getLuaState();
int isOpen = luaL_dofile(L, "/Users/game-netease/svn/gzhuabo/Menghuan/src/operation.lua");
if(isOpen != 0)
{
const char* iResult = lua_tostring(L, -1);
NSLog(@"Open Lua Error: %i, %s", isOpen, iResult);
handler(@{@"glanceInfo": @"ERROR"});
}
else
{
lua_getglobal(L, "getGlance");
/*
lua_call
第一个参数:函数的参数个数
第二个参数:函数返回值个数
*/
lua_call(L, 0, 1);
const char* iResult = lua_tostring(L, -1);
NSString *str = [NSString stringWithUTF8String:iResult];
NSLog(@"%@", str);
handler(@{@"glanceInfo": str});
}
NSArray *array = (NSArray *)context;
for (id object in array) {
Activity *obj = (Activity *)[NSKeyedUnarchiver unarchiveObjectWithData: object];
NSLog(@"name: %@, type: %@", obj.m_name, obj.m_type);
NSLog(@"time: %@", obj.m_time);
NSLog(@"donetime: %@", obj.m_doneTime);
}
//活动
@interface Activity : NSObject
@property(nonatomic, retain) NSString *m_name; //名称
@property(nonatomic, retain) NSString *m_type; //日常活动、限时活动、节日活动
@property(nonatomic, retain) NSNumber *m_doneTime; //已经完成次数
@property(nonatomic, retain) NSNumber *m_time; //每日次数
@property(nonatomic, retain) NSNumber *m_doneActiveness; //已经完成活跃度
@property(nonatomic, retain) NSNumber *m_activeness; //每日活跃度
@end #endif
#import <Foundation/Foundation.h>
#import "Activity.h" @implementation Activity
- (void) encodeWithCoder : (NSCoder *)encode {
[encode encodeObject:self.m_name forKey:@"name"];
[encode encodeObject:self.m_type forKey:@"type"];
[encode encodeObject:self.m_doneTime forKey:@"doneTime"];
[encode encodeObject:self.m_time forKey:@"time"];
[encode encodeObject:self.m_doneActiveness forKey:@"doneActiveness"];
[encode encodeObject:self.m_activeness forKey:@"activeness"];
} - (id)initWithCoder:(NSCoder *)aDecoder {
if(self = [super init])
{
self.m_name = [aDecoder decodeObjectForKey:@"name"];
self.m_type = [aDecoder decodeObjectForKey:@"type"];
self.m_doneTime = [aDecoder decodeObjectForKey:@"doneTime"];
self.m_time = [aDecoder decodeObjectForKey:@"time"];
self.m_doneActiveness = [aDecoder decodeObjectForKey:@"doneActiveness"];
self.m_activeness = [aDecoder decodeObjectForKey:@"activeness"];
}
return self;
}
@end
Apple-Watch开发1的更多相关文章
- Apple Watch开发快速入门教程
Apple Watch开发快速入门教程 试读下载地址:http://pan.baidu.com/s/1eQ8JdR0 介绍:苹果为Watch提供全新的开发框架WatchKit.本教程是国内第一本A ...
- 快速玩转Apple Pay开发
快速玩转Apple Pay开发 更新时间:2016年02月20日09时25分 来源:传智播客 Apple Pay 2016年2月18日上午,苹果公司宣布,与中国银联达成合作,正式在中国大陆上线Appl ...
- [转载]Apple Watch 开发详解
Apple Watch 开发详解 Apple Watch现在对于第三方开发者来说更多的还是一块额外的屏幕.暂时WatchKit没有能给出足够的接口.现在Watch App的主要运算逻辑需要依赖iPho ...
- Apple Watch 开发详解
Apple Watch 开发详解 Apple Watch现在对于第三方开发者来说更多的还是一块额外的屏幕.暂时WatchKit没有能给出足够的接口.现在Watch App的主要运算逻辑需要依赖iPho ...
- 为Apple Push开发的PHP PEAR 包:Services_Apple_PushNotification
Apple Push Notification Service:通过苹果服务器向app用户推送消息,无需启动app. 苹果官方文档:http://developer.apple.com/library ...
- Apple Watch开发了一些细节和总结
本文旨在总结最近Watch在发展中遇到的问题和细节 1.左右Watch真机调试问题 一般的情况下,你为IOS主应用创建了一个extention,比方说Today Extension .Xcode都会自 ...
- 苹果(APPLE)开发人员账号说明及注冊流程(99美元公司版/个人版及299美元企业版)
APPLE的政策是,要公布到APP STORE必须用99美元的个人版或公司版Apple Developer Programs,要在非商店外下载仅仅能使用299美元的企业版iOS Developer E ...
- Apple Pay--iOS开发
一.什么是Apple Pay? 1. 概念 Apple Pay,简单来说, 就是一种移动支付方式.通过Touch ID/ Passcode,用户可使用存储在iPhone 6, 6p等设备上的信用卡和借 ...
- Apple Watch开发之界面之间的正向传值
主要分两种,一种是故事板中通过segue进行的传值,第二种是使用代码. 贴代码 24行代码是代码进行传值 35是故事板中的
- iOS Apple Watch 开发
1. Watch OS 1 与 Watch OS 2 的区别 : OS 1 中界面运行在手表上,而代码(Extension)运行在手机端:OS 2 是纯正的手表原生(Native)应用 由于架构的改变 ...
随机推荐
- 了解SOA是什么!
面向服务架构 面向服务的体系结构(service-oriented architecture,SOA)是一个组件模型,它将应用程序的不同功能单元(称为服务)通过这些服务之间定义良好的接口和契约联系起来 ...
- 轻量级表格插件Bootstrap Table。拥有强大的支持固定表头、单/复选、排序、分页、搜索及自定义表头等功能。
Bootstrap Table是轻量级的和功能丰富的以表格的形式显示的数据,支持单选,复选框,排序,分页,显示/隐藏列,固定标题滚动表,响应式设计,Ajax加载JSON数据,点击排序的列,卡片视图等. ...
- apache pdfbox
转 http://www.blogjava.net/sxyx2008/archive/2010/07/23/326890.html 轻松使用apache pdfbox将pdf文件生成图 近期在项目中使 ...
- [BZOJ 1028] [JSOI2007] 麻将 【枚举+贪心判断】
题目链接:BZOJ - 1028 题目分析 枚举听的是哪种牌,再枚举成对的是哪种牌,再贪心判断: 从1到n枚举每一种牌,如果这种牌的个数小于0,就返回不合法. 将这种牌的张数 % 3, 剩下的只能和 ...
- E: Write error - write (28 No space left on device)
1:在终端中运行cd命令,提示: e: Write error - write (28 No space left on device) E: Cant mmap an empty file 2:使用 ...
- Two shortest
sgu185:http://acm.sgu.ru/problem.php?contest=0&problem=185 题意:找两条最短路径,没有边相交的最短路劲,并且输出路径. 题解:这一题和 ...
- delphi 连接 c++ builder 生成obj文件
delphi 连接 c++ builder 生成obj文件 delphi 可以连接c++ builder 生成OMF格式的obj文件,会报一个错.[DCC Error] E2065 Unsatisfi ...
- NOIP2014酱油记
尘埃落定,来补一下酱油记吧... day-1 晚上老师说有xyz的noip模拟赛,于是果断请假来做(shou)题(nve),题目真是理(S)性(X)愉(B)悦(K),然后就爆零了!感觉noip要爆零滚 ...
- Delphi 6 Web Services初步评估
Delphi 6 Web Services初步评估这是我刚到现在公司的时候(2001年8月份)所作的一份测试报告,现公布出来,希望能对大家有所帮助.因为当时d6刚刚发行,Web Service方面还存 ...
- Delphi 6 Web Services初步评估之三(转)
Delphi 6 Web Services初步评估之三(转) Delphi 6 Web Services初步评估之三(转)★ 测试总体印象:在整个测试中,对Delphi 6创建的Web Servi ...