文字列、UIImageなどのさまざまなオブジェクトを含む可変配列があります。これらは次のように並べ替えられます。
例:
BugData *bug1 = [[BugData alloc]initWithTitle:@"Spider" rank:@"123" thumbImage:[UIImage imageNamed:@"1.jpeg"]];
...
...
NSMutableArray *bugs = [NSMutableArray arrayWithObjects:bug1,bug2,bug3,bug4, nil];
つまり、基本的には、さまざまなプロパティを持つオブジェクトを含む配列です。
次のコードで単一の文字列をファイルに保存しようとしましたが、正常に機能していますが、オブジェクトを含む配列を保存しようとすると、空のplistファイルが表示されます。
NSString *docsDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString * path = [docsDir stringByAppendingPathComponent:@"data.plist"];
NSLog(@"%@",bugs); //Making sure the array is full
[bugs writeToFile:path atomically:YES];
私は何が間違っているのですか?