-2
是否可以在運行時通過代碼更改應用程序名稱 如果可能的話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];
}
你是對的,應用程序包是隻讀的。因此你不能編輯它們 – rckoenes