小编nic*_*ico的帖子

在 Swift 中将 PDF 图像转换为 Parse.com 的 NSData

我正在我的应用程序中创建 PDF,并希望将它们上传到 Parse.com。我需要先将 PDF 图像转换为NSData再上传。我知道在 Objective-C 中这是可能的:

NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:@"test.pdf"];
NSData *myData = [NSData dataWithContentsOfFile:pdfPath];
Run Code Online (Sandbox Code Playgroud)

但是,是否可以在 Swift 中将 PDF 文件转换为 PDF 文件NSData?以下不起作用:

var pdfPath: String = documentsDirectory.stringByAppendingPathComponent("test.pdf")
var myData: NSData = NSData.dataWithContentsOfFile(pdfPath)
Run Code Online (Sandbox Code Playgroud)

相关链接:

将 pdf 图像转换为 Parse.com 的 NSData

将 PDF 放入 NSData

objective-c parse-platform swift

1
推荐指数
1
解决办法
3572
查看次数

标签 统计

objective-c ×1

parse-platform ×1

swift ×1