3数据传输
3.1覆盖式后台传输
后台传输就是说不是数据立刻传输,而是当具备数据传输连接条件以后,watch和iphone之间自动同步数据,也就输说后台传输的数据是异步传输,具有延后性。
当第一发送的数据海没有传送出去,如果此时进行第二次数据传输,会覆盖第一次的数据,所以真正传输的是第二次的数据,第一次的数据会丢失。
(1) 发送数据
发送数据使用updateApplicationContext函数:
Declaration
SWIFT
func updateApplicationContext(_applicationContext: [String : AnyObject]) throws
OBJECTIVE-C
-(BOOL)updateApplicationContext:(NSDictionary<NSString *,
id>*)applicationContext
error:(NSError *_Nullable *)error
Parameters
applicationContext
A dictionary of property list values. Youdefine the meaning of the dictionary contents. This parameter must not be nil.
error
On input, a pointer to an error object. Onou