mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
use dataFromPropertyList for the addition
This commit is contained in:
parent
ce7ff5709b
commit
6ac9271fbc
2 changed files with 13 additions and 10 deletions
|
@ -54,12 +54,14 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
|
|||
NSError * myError = nil;
|
||||
NSData * dest;
|
||||
NSDictionary *loc;
|
||||
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||
switch (aFormat)
|
||||
{
|
||||
case NSPropertyListJSONFormat:
|
||||
dest = [NSJSONSerialization dataWithJSONObject:aPropertyList
|
||||
options:NSJSONWritingPrettyPrinted
|
||||
error:&myError];
|
||||
dest = [NSJSONSerialization
|
||||
dataWithJSONObject:aPropertyList
|
||||
options:loc != nil ? NSJSONWritingPrettyPrinted : 0
|
||||
error:&myError];
|
||||
if (myError != nil && anErrorString != NULL)
|
||||
{
|
||||
*anErrorString = [myError description];
|
||||
|
@ -67,7 +69,6 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
|
|||
return dest;
|
||||
case NSPropertyListObjectiveCFormat:
|
||||
case NSPropertyListSwiftFormat:
|
||||
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||
dest = [NSMutableData dataWithCapacity:1024];
|
||||
OAppend(aPropertyList, loc, 0, 2, aFormat, dest);
|
||||
return dest;
|
||||
|
|
|
@ -318,15 +318,17 @@ plFormatFromName(NSString *name)
|
|||
int
|
||||
dumpToFile(id obj, NSPropertyListFormat fmt, NSString *outfile)
|
||||
{
|
||||
NSError * anError;
|
||||
NSString * errorString = nil;
|
||||
NSFileHandle *fh;
|
||||
NSData * outdata = [NSPropertyListSerialization dataWithPropertyList:obj
|
||||
format:fmt
|
||||
options:0
|
||||
error:&anError];
|
||||
NSData * outdata =
|
||||
[NSPropertyListSerialization dataFromPropertyList:obj
|
||||
format:fmt
|
||||
options:0
|
||||
errorDescription:&errorString];
|
||||
if (anError)
|
||||
{
|
||||
GSPrintf(stderr, @"Dumping %@ as format %@ - %@\n", obj, fmt, anError);
|
||||
GSPrintf(stderr, @"Dumping %@ as format %@ - %@\n", obj, fmt,
|
||||
errorString);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue