0
我有我創建一個plist文件,但不是寫入文件,我想打印出它的內容作爲一個字符串的NSLog:印刷的plist文件的NSLog
NSMutableDictionary* root = [NSMutableDictionary dictionaryWithCapacity:1];
NSMutableArray* puzzle = [NSMutableArray arrayWithCapacity: [self.puzzlePieces count] ];
root[@"puzzle"] = puzzle;
[self.puzzlePieces enumerateObjectsUsingBlock:^(KTPuzzlePiece* piece, NSUInteger idx, BOOL *stop) {
NSMutableDictionary* pieceInfo = [piece.pieceInfo mutableCopy];
pieceInfo[@"x"] = [NSNumber numberWithFloat: piece.position.x];
pieceInfo[@"y"] = [NSNumber numberWithFloat: piece.position.y];
[puzzle addObject:pieceInfo];
}];
NSData *data = [NSPropertyListSerialization dataFromPropertyList:root
format:NSPropertyListXMLFormat_v1_0
errorDescription:nil];
但是,以下低於輸出十六進制值
NSLog(@"Data: %@", data);
NSLog(@「Data:%@」,root); – NeverBe
這不會輸出XML字符串,例如在純文本編輯器中打開plist時發現的XML字符串。 – 1dayitwillmake