각 항목이 사전 인 기본 사전이 있습니다. 이것을 plist에 저장하고 나중에 내용을 검색해야합니다. IPHONE : plist에서 사전 사전 저장 및 검색
이
내가// create a dictionary to store a fruit's characteristics
NSMutableDictionary *fruit = [[NSMutableDictionary alloc] init];
[fruit setObject:quantity forKey:@"quantity"];
[fruit setObject:productID forKey:@"productID"];
[fruit setObject:nameID forKey:@"nameID"];
// create a dictionary to store all fruits
NSMutableDictionary *stock = [[NSMutableDictionary alloc] init];
[stock setObject:fruit forKey:@"nameID"];
... 주식 사전에 모든 과일을 추가 한 후하는 PLIST
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"stock.plist"];
NSMutableDictionary *stock = [NSMutableDictionary dictionaryWithContentsOfFile:path];
[stock writeToFile:path atomically:YES];
에 주식을 쓰기에 사전을 저장하고있는 무슨이다 사전을 복원, 나는 사용
NSMutableDictionary *stock = [NSMutableDictionary dictionaryWithContentsOfFile:path];
... 그러나 이것은 파일에 아무것도 저장하지 않습니다 ... 내가 뭘 놓치고 있습니까?
도움을 주셔서 감사합니다.
감사합니다. 이 줄 [주식 writeToFile : 경로 atomically : 예]; 사전을 사전 순으로 직렬화하여 파일에 저장 하시겠습니까? dictionaryWithContentsOfFile이 동일한 구조를 다시 읽습니까? – SpaceDog