2012-02-22 6 views
0

私はまだiPhoneアプリの開発にかなり新しいです。私はあなたの助けが必要です。私はimageData.plistをAppleのPhotoScroller exampleに移植しようとしていますが、あなたは完全に画像フォルダのすべての画像に基づいてこのplistファイルをプログラム的に埋め込む方法を教えてください。私が持っているもう1つの課題は、フォルダ内に任意の数の未知の画像をいつでも置くことができるということです。以下は、plistファイルのスナップショットです。 plistのテーブルのPhotoScrollerでImageData.plistを埋め込む例

定義

 
Item 0 Dictionary (3 items)
height Number 400
width Number 290
name string Lake
Item 1 Dictionary (3 items)
height Number 400
width Number 290
name string Tree
Item 2 Dictionary (3 items)
height Number 400
width Number 290
name string Shed
Item 3 Dictionary (3 items)
height Number 400
width Number 290
name string Rock

私はこれを達成するためにNSDictionaryのクラスとWRITETOFILEを使用する必要があることを知っているが、どのように私は助けを必要とし、これについて行くことに。

答えて

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]; 
関連する問題