0

私はまだiPhoneアプリの開発にかなり慣れていないので、あなたの助けが必要です。AppleのPhotoScrollerの例のimageData.plist に自分の画像を入力しようとしていますが、完全な画像フォルダー内のすべての画像に基づいて、このplistファイルをプログラムで入力する方法を教えてください。私が抱えているもう1つの課題は、未知の画像をいつでもフォルダ内に配置できることです。以下は、plistファイルのスナップショットです。

plistテーブルの定義

アイテム0辞書(3アイテム)
高さ番号400
幅番号290
名前文字列湖
アイテム1辞書(3アイテム)
高さ番号400
幅番号290
名前文字列ツリー
アイテム2辞書(3アイテム)
高さ番号400
幅番号290
名前文字列小屋
アイテム3辞書(3アイテム)
高さ番号400
幅番号290
名前文字列ロック

これを実現するには、NSDictionaryクラスとwriteToFileを使用する必要があることはわかっていますが、これを実行するには、ヘルプが必要です。

4

1 に答える 1

0

NSDictionary の配列?

NSMutableArray *dicts = [NSMutableArray arrayWithCapacity:10];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:400], @"height", [NSNumber numberWithInt:290], @"width", @"Lake", @"name", nil];
[dicts addObject:dict];
//and so on...

NSFileManager *fileManager = [NSFileManager defaultManager];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"filename.plist"];

[dicts writeToFile:filePath atomically:YES];
于 2012-02-22T20:36:35.647 に答える