【发布时间】:2015-06-23 02:12:21
【问题描述】:
我正在寻找助手。在我的情况下,我有诸如
之类的文件- RN150622103444544_pr.pdf
- RN150622103444544_ID_GD.pdf
- RN150622103444544_CA.xml
我的问题是如何仅通过引用 RN150622103444544 来删除所有文件。 目前我的代码正在一一删除。 以下是我的示例代码
-(void)deleteOldPdfs:(NSString *)proposal
{
NSError *error = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
if([fm fileExistsAtPath:[FormsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_pr_1.pdf",proposal]]])
{
[fm removeItemAtPath:[FormsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_pr_1.pdf",proposal]] error:&error];
}
if([fm fileExistsAtPath:[FormsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_id_GD.pdf", proposal]]]){
[fm removeItemAtPath:[FormsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_id_GD.pdf", proposal]] error:&error];
}
if([fm fileExistsAtPath:[FormsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_CA.xml", proposal]]]){
[fm removeItemAtPath:[FormsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_CA.xml",proposal]] error:&error];
}
}
提前致谢
【问题讨论】:
标签: ios objective-c iphone xcode string