Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 按标题更改pdf的名称_Iphone_Objective C_Pdf - Fatal编程技术网

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]