Iphone 按标题更改pdf的名称
在我的应用程序中,我获得了一个名为Iphone 按标题更改pdf的名称,iphone,objective-c,pdf,Iphone,Objective C,Pdf,在我的应用程序中,我获得了一个名为PDF的标题,该标题保存在我的plist中,静态名称如s.PDF 之后,我找到了该pdf的标题,现在我想用我得到的标题名保存同一个pdf,并替换旧名称s.pdf 那么我该怎么做呢?您可能需要NSFileManagercopyItemAtPath:toPath:error: 将给定路径中指定的目录或文件复制到文件系统中由另一路径标识的其他位置 示例这不是一个完整的代码,仅供解释: // This will get you the Bundle Path. NSS
PDF
的标题,该标题保存在我的plist
中,静态名称如s.PDF
之后,我找到了该pdf的标题,现在我想用我得到的标题名保存同一个pdf,并替换旧名称s.pdf
那么我该怎么做呢?您可能需要NSFileManager
copyItemAtPath:toPath:error:
将给定路径中指定的目录或文件复制到文件系统中由另一路径标识的其他位置
示例这不是一个完整的代码,仅供解释:
// This will get you the Bundle Path.
NSString*path = [[NSBundle mainBundle] resourcePath];
// This will get your PDF in the Bundle Path.
[[NSBundle mainBundle] pathForResource:@"s" ofType:@"pdf"]
// Copy your file to the same destination but with different name.
[[NSFileManager defaultManager] copyItemAtPath:OldFileNameInBundle
toPath:NewFileNameInBundle
error:&err]