3.3 文件传输
(1)发送文件
发送文件也是后台模式。
发送文件函数transferFile:metadata:声明如下:
Declaration
SWIFT
func transferFile(_ file: NSURL,
metadata metadata: [String : AnyObject]?) -> WCSessionFileTransfer
OBJECTIVE-C
- (WCSessionFileTransfer*)transferFile:(NSURL *)file
metadata:(NSDictionary<NSString *,
id> *)metadata
Parameters
file
A file-based URL that identifies the fileto send. The specified file must be readable by the current app. This parametermust not be nil.
metadata
An optional dictionary containingadditional data to send. The values of the dictionary must all be property listobject types. You may specify nil for this parameter.
Return Value
A file transfer object containing the fileand dictionary being sent. You can use this