无法从mainBundle中删除文件 [英] Can't remove files from mainBundle

查看:66
本文介绍了无法从mainBundle中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从主捆绑包中删除文件.当我从XCODE 4.2中的支持文件中手动删除它们时.当我运行我的应用程序时,它们仍会显示.我已经用显示包内容"打开了应用程序文件,并从那里手动删除了它们,当我运行该应用程序时它们仍然显示.我已经从模拟器和库中的〜/applications文件夹中删除了该应用程序,并且存在相同的行为.我想念什么吗?

I am having trouble removing files from my main bundle. When I delete them manually from support files in XCODE 4.2. They still show up when I run my app. I have opened up the app file with "show package contents" and manually deleted them from there and they still show up when I run the app. I have deleted the app from the simulator and from the ~/applications folder in library and the same behavior exists. Am I missing something?

背景:我有一个助手应用程序,可以将文件拖放到支持文件"文件夹中,然后运行该程序,以将文件从KML转换为自定义XML,以便通过服务器下载到设备将其用于其他应用程序.我使用以下代码从主捆绑包创建文件名数组,并将其传递给解析器.我有问题,因为它包括从捆绑软件中删除/删除的文件,我不知道为什么.任何帮助将不胜感激.

Background: I have a helper app that I can drop files into the "support files" folder and run in order to convert them from KML to custom XML for use in another app via server downloads to the device. I create an array of file names from the main bundle with the code below and pass that to the parser. I have issues because it is including the deleted/removed files from the bundle and I can't figure out why. Any help would be appreciated.

-(NSArray*)findKMLFilesInMainBundle{
NSString *path = [[NSBundle mainBundle]resourcePath];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = [[NSError alloc]init];
NSMutableArray *kmlArray = [[NSMutableArray alloc]initWithCapacity:10];

NSArray *files = [fileManager contentsOfDirectoryAtPath:path error:&error];
unichar buffer[5];

//now seach for the kml files
for (NSString *fileName in files){
    NSLog(@"%@",fileName);
    int count = [fileName length];
    int start = count - 3;
    NSRange range = {start,3};


    [fileName getCharacters:buffer range:range];
    NSString *endString = [NSString stringWithCharacters:buffer length:3];
    if ([endString isEqualToString:@"kml"]){
        NSString *kmlFileName = [fileName stringByDeletingPathExtension];
        NSLog(@"kmlFilename%@",kmlFileName);
        [kmlArray addObject:kmlFileName];

    }
}
for (NSString *name in kmlArray){
    NSLog(@"file = %@",name);
}

return kmlArray;

}

推荐答案

按住⌥选项并选择Product→从菜单栏中清除构建文件夹....此操作的默认快捷方式是⌥⇧⌘K.

Hold down ⌥ Option and choose Product → Clean Build Folder... from the menu bar. The default shortcut for this action is ⌥⇧⌘K.

这篇关于无法从mainBundle中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆