-1
A
답변
1
,이 클래스는 파일 initWithContentsOfFile:(NSString *)path
에서있는 NSDictionary를 제작하는 방법이있다. 다음과 같이 할 수 있습니다 :
여기서 myDictionary는 plist 이름입니다 (plist가 자원 번들의 경우). 당신은 방법으로 디스크에 PLIST를 작성할 수 있습니다
[dict writeToFile:filePath atomically: YES];
를 참고 FilePath 목적지의 경로입니다.
0
이 tutorial의 Plist 파일 예제를 참조하십시오. 당신이 NSDictionary reference에서에서 찾을 수 있듯이
// Look in Documents for an existing plist file
NSArray *paths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
myPlistPath = [documentsDirectory stringByAppendingPathComponent:
[NSString stringWithFormat: @"%@.plist", plistName] ];
[myPlistPath retain];
// If it's not there, copy it from the bundle
NSFileManager *fileManger = [NSFileManager defaultManager];
if (![fileManger fileExistsAtPath:myPlistPath]) {
NSString *pathToSettingsInBundle = [[NSBundle mainBundle]
pathForResource:plistName ofType:@"plist"];
}
NSArray *paths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *path = [documentsDirectoryPath
stringByAppendingPathComponent:@"myApp.plist"];
NSMutableDictionary *plist = [NSDictionary dictionaryWithContentsOfFile: path];
myKey = (int)[[plist valueForKey:@"myKey"] intValue];
myKey2 = (bool)[[plist valueForKey:@"myKey2"] boolValue];
[plist setValue:myKey forKey:@"myKey"];
[plist writeToFile:path atomically:YES];
+0
답장을 보내 주셔서 감사합니다 ... – donkarai
관련 문제
- 1. NSMutableDictionary
- 2. NSMutableDictionary 삭제
- 3. iPhone의 NSMutableDictionary
- 4. 역순 NSMutableDictionary
- 5. [[NSMutableDictionary alloc] initWithObjects : ...]와 [NSMutableDictionary dictionaryWithObjects : ...]의 차이점은 무엇입니까?
- 6. UIProgressBar로드 중 NSMutableDictionary
- 7. NSMUtableDictionary 할당 해제 문제
- 8. NSMutableDictionary 원인 EXC_BAD_ACCESS
- 9. NSMutableDictionary 키 값
- 10. NSMutableSets의 NSMutableDictionary ... 이것을 정렬
- 11. 배열의 NSMutableDictionary 편집
- 12. NSMutableDictionary 변경 사항을 관찰하십시오.
- 13. NSMutableDictionary 열거 형
- 14. NSMutableDictionary 스레드 안전성
- 15. Objective-C NSMutableDictionary 사라짐
- 16. 클래스 간 NSMutableDictionary 액세스
- 17. 용량이 NSMutableDictionary 인 경우
- 18. NSMutableDictionary 중복 값 저장
- 19. NSMutableDictionary 이상한 문제
- 20. NSMutableDictionary 메모리 누수
- 21. NSMutableDictionary 및 NSArray
- 22. NSMutableDictionary 데이터 정렬
- 23. iPhone : NSMutableDictionary 키
- 24. NSMutableDictionary 싱글 톤 문제
- 25. NSMutableDictionary plist로 인한로드 문제
- 26. NSMutableDictionary 메모리 문제
- 27. NSMutableDictionary 대 CFMutableDictionary
- 28. Objective C NSMutableDictionary 메모리 관리
- 29. 싱글 톤, NSMutableDictionary 및 plist
- 30. 개체별로 NSMutableDictionary 키를 정렬 하시겠습니까?
Bermardi님께 도움을 주신 .. – donkarai