3.2队列式后台传输
(1)发送数据
队列式后台传输,后一次的数据不会覆盖前一次的数据,而是把所有的数据按照次序全部发送出去。也是发送字典数据,是个大量数据传输。
队列时发送字典数据函数:transferUserInfo声明:
Declaration
SWIFT
func transferUserInfo(_ userInfo: [String :AnyObject]) -> WCSessionUserInfoTransfer
OBJECTIVE-C
- (WCSessionUserInfoTransfer*)transferUserInfo:(NSDictionary<NSString *,
id> *)userInfo
Parameters
userInfo
A dictionary of property list values thatyou want to send. You define the contents of the dictionary that yourcounterpart supports. This parameter must not be nil.
Return Value
A transfer object that you can use tomonitor and cancel the operation.
(2)接收数据
接收端会把数据存放在WCSession的WCSessionUserInfoTransfer属性中,但是我们不能直接读取,需要获取函数outstandingUserInfoTransfers来获取。
Declaration
SWIFT
var outstandingUserInfoTransfers:[WCSessionUserInfoTransfer] { get }
OBJECTIVE-C
@property(nonatomic, readonly, copy)NSArray <WCSessionUserInfoTransfer *> *outstandingUserInfoTransfers