3 つのエンティティ (購入、アイテム、画像) を持つデータ モデルがあります。購入がメインで、他の 2 つは関連する属性です。
データを Web サーバーに送信できるようにする必要があり、base64 でエンコードする必要があります。ネットからダウンロードしたエンコードとデコードを処理するクラスがいくつかあります。これらは NSData クラスのカテゴリです。しかし、それらを使用すると、null 文字列が返されます。
// For Error Information
NSError *error;
// Create a File Manager
NSFileManager *fileManager = [NSFileManager defaultManager];
// Point to the Documents Directory
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
// File we want to create in the Documents Directory
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"dataArray.txt"];
NSString *joined = [self.dataList componentsJoinedByString:@","];
NSData *myData = [NSData dataWithBase64EncodedString:joined];
NSLog(@"%@", myData); // THIS IS NULL
[myData writeToFile:filePath atomically:YES];
SO配列はこれを吐き出します...
<Purchase: 0x502b7a0> (entity: Purchase; id: 0x502a620 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Purchase/p22> ; data: {
amount = 123.56;
image = 0x502c7b0 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Image/p11>;
items = "<relationship fault: 0x5024900 'items'>";
latitude = 37.331689;
longitude = -122.030731;
name = "Macy's";
thumbnailImage = "(...not nil..)";
timestamp = 2010-02-18 18:03:03 -0500;
type = nil;
}),<Purchase: 0x502bdf0> (entity: Purchase; id: 0x502a630 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Purchase/p20> ; data: {
amount = 12.34;
image = 0x502c8e0 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Image/p9>;
items = "<relationship fault: 0x502ef40 'items'>";
latitude = 37.331689;
longitude = -122.030731;
name = Rippers;
thumbnailImage = "(...not nil..)";
timestamp = 2010-02-18 12:18:34 -0500;
type = Travel;
}),<Purchase: 0x502c0e0> (entity: Purchase; id: 0x502a640 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Purchase/p21> ; data: {
amount = 5.56;
image = 0x502ca40 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Image/p10>;
items = "<relationship fault: 0x502f6a0 'items'>";
latitude = 37.331689;
longitude = -122.030731;
name = "Roy Rogers";
thumbnailImage = "(...not nil..)";
timestamp = 2010-02-18 17:45:03 -0500;
type = Clothing;
}),<Purchase: 0x502c320> (entity: Purchase; id: 0x502a650 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Purchase/p16> ; data: {
amount = 5.52;
image = nil;
items = "<relationship fault: 0x502f9e0 'items'>";
latitude = 37.331689;
longitude = -122.030731;
name = heariam;
thumbnailImage = nil;
timestamp = 2010-02-18 09:41:35 -0500;
type = nil;
})
これをbase64文字列にエンコードして、Webサーバーに電子メールで送信するにはどうすればよいですか
どんな助けでも大歓迎です、または正しい方向へのポイントでさえ、私はまだプログラミングに非常に慣れていません。