开发者

changing the name of pdf by the title

In my application I obtain a title of PDF which is saved in my plist with static name which is i given like s.pdf

After that I find the title of that pdf and now I want to save th开发者_JS百科e same pdf with that title name which I got and also replacing the old name which is s.pdf So how can I do that?


You probably going to need NSFileManager copyItemAtPath:toPath:error:

Copies the directory or file specified in a given path to a different location in the file system identified by another path.

Example This is not a complete code it's for explanation only:

// 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]

NSFileManager copyItemAtPath

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜