したがって、ファイルに保存する必要があるオブジェクトの NSMutableArray があります。writeToFile
このメソッドが生成する .plist 形式では許可されていない NSNull 値があるため、メソッドで保存することはできません。
したがって、ファイルを NSString として保存することで、ファイルをディスクに保存しています。
NSString *content = [NSString stringWithFormat:@"%@",orders];
[content writeToFile:ordersFilePath atomically:NO];
次のようなファイルが生成されます。
(
{
ZBILLINGADDRESS1 = "";
ZBILLINGADDRESS2 = "";
ZBILLINGCITY = "";
ZBILLINGCOUNTRY = "";
ZBILLINGSTATE = "";
ZBILLINGZIP = "";
ZCANCELDATE = "<null>";
ZCATALOGCODE = "";
ZCATALOGNAME = "";
ZCONTACTEMAIL = "";
ZCONTACTFAX = "";
ZCONTACTNAME = " ";
ZCONTACTPHONE = "";
ZCONTAINERCUBES = 0;
ZCONTAINERNAME = "";
ZCURRENCYCODE = "<null>";
ZCUSTOMERID = 0;
ZCUSTOMERNAME = "Dupe offline Test";
ZCUSTOMERNUMBER = 1297145;
ZDISCOUNT = 0;
ZDONOTSHIPBEFORE = "<null>";
ZEXPORTDATE = "-63113886238";
ZEXPORTED = 1;
ZFOB = "";
ZFREIGHTTERM = "";
ZISCONTAINER = 0;
ZISDEFAULT = 0;
ZISDELETED = 0;
ZISPLACED = 0;
ZMANUFACTURERID = 18;
ZMARKETNAME = "";
ZNOTES = "last second note";
ZORDERDATE = 372571200;
ZORDERGUID = "5650d30a-9316-436a-87e9-1e0ead3af8d7";
ZORDERID = 84340;
ZORDERSTATUS = Accept;
ZORDERTOTAL = 200;
ZORDERTYPE = "";
ZORIGIN = "";
ZPONUMBER = 3;
ZPRICELEVEL = 2;
ZREPNUMBER = 1;
ZSALESREPID = 235;
ZSHIPDATE = 373176000;
ZSHIPPINGTOTAL = 0;
ZSHIPTOADDRESS1 = "";
ZSHIPTOADDRESS2 = "";
ZSHIPTOCITY = "";
ZSHIPTOCOMPANYNAME = "";
ZSHIPTOCONTACTEMAIL = "";
ZSHIPTOCONTACTNAME = "";
ZSHIPTOCONTACTPHONE = "";
ZSHIPTOCOUNTRY = "";
ZSHIPTOFAX = "";
ZSHIPTOSTATE = "";
ZSHIPTOZIP = "";
ZSHIPVIA = "";
ZSOURCE = ipad;
ZSUBTOTAL = 200;
ZTAXRATE = 0;
ZTAXTOTAL = 0;
ZTERMS = "";
ZWRITTENBYNAME = "";
ZWRITTENFORNAME = "";
ZWRITTENFORREPNUMBER = "";
ZWRITTENFORREPNUMBER1 = "<null>";
"Z_ENT" = 17;
"Z_OPT" = 5;
"Z_PK" = 450;
}
)
問題は、これを NSArray としてリロードしようとすると、null 値が返されることです。
NSString *str = [NSString stringWithContentsOfFile:ordersFilePath encoding:NSUTF8StringEncoding error:NULL];
NSArray *loadedOrders = [[NSArray alloc] initWithContentsOfFile:str];
ここで何が欠けていますか?