在当前时间更改应用名称

时间:2011-12-05 12:35:57

标签: iphone ipad

是否可以在运行时通过代码更改应用名称 如果可能,PLZ快速回复。 我正在使用此代码 `

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
           NSString *documentsDirectory = [paths objectAtIndex:0];


           NSString *myPathDocs =  [documentsDirectory stringByAppendingPathComponent:@"SelectedImages.plist"];

           if ([[NSFileManager defaultManager] fileExistsAtPath:myPathDocs])
           {
               NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
               NSFileManager *fileManager = [NSFileManager defaultManager];
          [fileManager copyItemAtPath:resourcePath toPath:myPathDocs error:NULL];



               NSDictionary *dic = [[NSDictionary alloc]initWithContentsOfFile:myPathDocs];

               //dic = [[NSBundle mainBundle] infoDictionary];
               NSMutableArray *arr =[dic objectForKey:@"CFBundleIconFiles"];          
               NSLog(@"Number of items %d",[arr count]);
               NSLog(@"object %@",[arr objectAtIndex:0]);
               [arr replaceObjectAtIndex:0 withObject:@"Icon.png"];
                 NSLog(@"object %@",[arr objectAtIndex:0]);
               [arr writeToFile:myPathDocs atomically:YES] ;

               [NSBundle bundleWithPath:myPathDocs];

               //[[NSBundle mainBundle]setValuesForKeysWithDictionary:dic];
                [arr release]; 
           }

1 个答案:

答案 0 :(得分:2)

您看到的代码似乎是尝试更改图标,而不是名称。在非越狱手机AFAIK上无法使用其中任何一个。您无法编辑现有应用的捆绑包。