정확히 .plist 파일은 무엇이며 어떻게 사용합니까? 내가 xcode에서 이것을 볼 때, 어떤 종류의 템플릿을 생성하는 것으로 보입니다. 내용을 배열로 밀어 plist 파일의 데이터를 추출 할 수있는 방법이 있습니까? 또한 .plist의 출처는 어디서 볼 수 있습니까?Plist : 사용법 및 사용 방법
7
A
답변
13
쉽게 다음 코드를 사용하여 배열에 PLIST의 내용을 얻을 수 있습니다 (다음 PLIST 배열했다 경우는 여기에 NSArray
형식 열거 것
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"plist"];
contentArray = [NSArray arrayWithContentsOfFile:filePath];
PLIST가 해당 단지 XML 파일입니다 : 우리는 여기에 Xcode 프로젝트의 일부)의 'file.plist'라는 파일을 여는 것 애플이 디자인 일부 DTD (데이터 형식 사전)는 DTD는 여기에서 볼 수있다 :
은 "객체"및 XML 파일에 포함 할 수있는 데이터 유형을 설명 things- 용 기타 DTD 단체 중에서 .
7
Plist는 속성 목록의 약자입니다. Apple에서 데이터를 저장하는 데 사용되는 파일 형식 일뿐입니다.
당신은 여기에 더 많은 정보를 얻을 수 있습니다 : http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man5/plist.5.html
당신은 속성 목록에서 읽고 싶은 경우
는 여기에서 확인 :
// Get the location of the plist
// NSBundle represents the main application bundle (.app) so this is a shortcut
// to avoid hardcoding paths
// "Data" is the name of the plist
NSString *path = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"];
// NSData is just a buffer with the binary data
NSData *plistData = [NSData dataWithContentsOfFile:path];
// Error object that will be populated if there was a parsing error
NSString *error;
// Property list format (see below)
NSPropertyListFormat format;
id plist;
plist = [NSPropertyListSerialization propertyListFromData:plistData
mutabilityOption:NSPropertyListImmutable
format:&format
errorDescription:&error];
plist
가 PLIST에서 최고 수준의 컨테이너가 어떤했다 될 수 있습니다. 예를 들어 plist가 사전 인 경우 plist
은 NSDictionary
이됩니다.
enum {
NSPropertyListOpenStepFormat = kCFPropertyListOpenStepFormat,
NSPropertyListXMLFormat_v1_0 = kCFPropertyListXMLFormat_v1_0,
NSPropertyListBinaryFormat_v1_0 = kCFPropertyListBinaryFormat_v1_0
}; NSPropertyListFormat;
관련 문제
- 1. plist 사용 방법
- 2. 해시지도 사용법 및 아이디어
- 3. XORing 색상 및 사용법
- 4. \ n NSSting * 및 .plist
- 5. Plist NSMutableArray 및 NSMutableDictionary 문제
- 6. plist 데이터를 읽는 방법
- 7. GObject.add_emission_hook 사용법
- 8. 싱글 톤, NSMutableDictionary 및 plist
- 9. 번들 표시 이름 및 plist
- 10. SQLite, plist 또는 다른 것을 사용 하시겠습니까?
- 11. 바이너리 plist 대 보통 plist
- 12. iOS 프로그래밍에서 pList 사용하는 방법
- 13. .plist 파일로 UIPickerView를 채우는 방법?
- 14. plist 또는 NSUserDefaults를 보호하는 방법
- 15. mod의 사용법 : instance_method?
- 16. 아이폰 .plist 파일에서 여러 줄을 선택하는 방법?
- 17. plist 작성
- 18. 부스트의 "cstdint"사용법
- 19. gzip 및 사용 방법
- 20. SetProcessWorkingSetSize 사용법
- 21. LauncherActivity 사용법
- 22. JScrollPane 사용법
- 23. 사용법 #include
- 24. 펄 모듈 사용법?
- 25. 유닛 테스트 및 Nunit 애플리케이션 사용법 알아보기
- 26. PyObjC 및 method_exchangeImplementations : 충돌이 발생했습니다. 올바른 사용법?
- 27. Delphi Shell IExtractIcon 사용법 및 결과
- 28. 비디오 램 사용법 iphone
- 29. facebook xfbml 사용법
- 30. 실용적인 포인터 사용법 (C++)
코드를 보내 주셔서 감사합니다. 여기서 한 일을 한 줄씩 나에게 말할 수 있습니까? 또한 이러한 데이터 형식 중 일부는 (NSBundle, NSData, NSPropertyListFormat, NSPropertyListSerialization) 무엇인지 확실하지 않습니다. – locoboy
@ cfarm54 내 게시물을 더 많은 인라인 코멘트로 업데이트했습니다. – AdamH