2014-04-21 5 views

답변

0

plist 파일에 값을 추가하려고 시도하십시오.

NSString* plistPath = nil; 
NSFileManager* manager = [NSFileManager defaultManager]; 
if (plistPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Contents/Info.plist"]) 
{ 
    if ([manager isWritableFileAtPath:plistPath]) 
    { 
     NSMutableDictionary* infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath]; 
     [infoDict setObject:[NSNumber numberWithBool:hidden] forKey:@"LSUIElement"]; 
     [infoDict writeToFile:plistPath atomically:NO]; 
     [manager changeFileAttributes:[NSDictionary dictionaryWithObject:[NSDate date] forKey:NSFileModificationDate] atPath: [[NSBundle mainBundle] bundlePath]]; 
    } 
} 

그리고 이것은 plist 파일에서 가치를 얻는 것입니다.

// Get the value for the "Bundle version" from the Info.plist 
[mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"]; 

// Get the bundle identifier 
[mainBundle bundleIdentifier]; 

// Reads the value of the custom key I added to the Info.plist 
    NSString *value = [mainBundle objectForInfoDictionaryKey:@"key"]; 

//Log the value 
NSLog(@"Value = %@", value); 

NSBundle* mainBundle = [NSBundle mainBundle];  
는이 코드가 당신을 위해 유용 바랍니다.