在 PhotoScroller 示例中填充 ImageData.plist

发布于 2025-01-08 02:56:44 字数 910 浏览 1 评论 0原文

我对 iPhone 应用程序开发还很陌生,我需要你的帮助。我正在尝试填充 Apple 的 PhotoScroller 示例中的 imageData.plist< /a> 包含我自己的图像,您能否指导我如何根据完整图像文件夹中的所有图像以编程方式填充此 plist 文件?我面临的另一个挑战是,可以随时将任意数量的未知图像放入文件夹中。下面是 plist 文件的快照。

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 来实现此目的,但如何实现此目的我需要帮助。

I am still fairly new to iPhone app development and I need your help. I am trying to populate the imageData.plist in Apple's PhotoScroller example with images of my own, can you please guide me on how to populate this plist file programmatically, based on all the images in the full images folder? The other challenge I have is that any number of unknown images could be placed inside the folder at any time. Below is a snapshot of the plist file.

Definition of plist table

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

I know that I have to use NSDictionary class and writeToFile to achieve this, but how to go about this I need help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

窝囊感情。 2025-01-15 02:56:44

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];

An array of NSDictionarys?

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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文