mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +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;
|
NSError * myError = nil;
|
||||||
NSData * dest;
|
NSData * dest;
|
||||||
NSDictionary *loc;
|
NSDictionary *loc;
|
||||||
|
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||||
switch (aFormat)
|
switch (aFormat)
|
||||||
{
|
{
|
||||||
case NSPropertyListJSONFormat:
|
case NSPropertyListJSONFormat:
|
||||||
dest = [NSJSONSerialization dataWithJSONObject:aPropertyList
|
dest = [NSJSONSerialization
|
||||||
options:NSJSONWritingPrettyPrinted
|
dataWithJSONObject:aPropertyList
|
||||||
error:&myError];
|
options:loc != nil ? NSJSONWritingPrettyPrinted : 0
|
||||||
|
error:&myError];
|
||||||
if (myError != nil && anErrorString != NULL)
|
if (myError != nil && anErrorString != NULL)
|
||||||
{
|
{
|
||||||
*anErrorString = [myError description];
|
*anErrorString = [myError description];
|
||||||
|
@ -67,7 +69,6 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
|
||||||
return dest;
|
return dest;
|
||||||
case NSPropertyListObjectiveCFormat:
|
case NSPropertyListObjectiveCFormat:
|
||||||
case NSPropertyListSwiftFormat:
|
case NSPropertyListSwiftFormat:
|
||||||
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
|
||||||
dest = [NSMutableData dataWithCapacity:1024];
|
dest = [NSMutableData dataWithCapacity:1024];
|
||||||
OAppend(aPropertyList, loc, 0, 2, aFormat, dest);
|
OAppend(aPropertyList, loc, 0, 2, aFormat, dest);
|
||||||
return dest;
|
return dest;
|
||||||
|
|
|
@ -318,15 +318,17 @@ plFormatFromName(NSString *name)
|
||||||
int
|
int
|
||||||
dumpToFile(id obj, NSPropertyListFormat fmt, NSString *outfile)
|
dumpToFile(id obj, NSPropertyListFormat fmt, NSString *outfile)
|
||||||
{
|
{
|
||||||
NSError * anError;
|
NSString * errorString = nil;
|
||||||
NSFileHandle *fh;
|
NSFileHandle *fh;
|
||||||
NSData * outdata = [NSPropertyListSerialization dataWithPropertyList:obj
|
NSData * outdata =
|
||||||
format:fmt
|
[NSPropertyListSerialization dataFromPropertyList:obj
|
||||||
options:0
|
format:fmt
|
||||||
error:&anError];
|
options:0
|
||||||
|
errorDescription:&errorString];
|
||||||
if (anError)
|
if (anError)
|
||||||
{
|
{
|
||||||
GSPrintf(stderr, @"Dumping %@ as format %@ - %@\n", obj, fmt, anError);
|
GSPrintf(stderr, @"Dumping %@ as format %@ - %@\n", obj, fmt,
|
||||||
|
errorString);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue