Iphone 从plist加载图像

Iphone 从plist加载图像,iphone,iphone-sdk-3.0,ios4,plist,Iphone,Iphone Sdk 3.0,Ios4,Plist,我正在从这样的服务器加载图像 - (id)init { self = [ super init ]; if (self != nil) { covers = [ [ NSMutableArray alloc ] init ]; for(int i = 1; i < 6; i++) { NSLog(@"Loading demo image %d\n", i); UIImage *image = [ [ UIImage alloc ] init

我正在从这样的服务器加载图像

- (id)init {
self = [ super init ];
if (self != nil) {
    covers = [ [ NSMutableArray alloc ] init ];

    for(int i = 1; i < 6; i++) {
        NSLog(@"Loading demo image %d\n", i);
        UIImage *image = [ [ UIImage alloc ] initWithData:
                          [ NSData dataWithContentsOfURL:
                           [ NSURL URLWithString: [ NSString stringWithFormat:
                                                   @"http://www.xyz.com/1%d.png", i ] ] ]
                          ];





        [ covers addObject: image ];
    }
}
return self;
-(id)init{
self=[super init];
if(self!=nil){
covers=[[NSMutableArray alloc]init];
对于(int i=1;i<6;i++){
NSLog(@“正在加载演示映像%d\n”,i);
UIImage*image=[[UIImage alloc]initWithData:
[NSData DATA with contents sofURL:
[NSURL URLWithString:[NSString stringWithFormat:
@"http://www.xyz.com/1%d.png“,我]]]
];
[对象:图像];
}
}
回归自我;
}


现在我想从plist文件而不是url加载图像。谁能告诉我怎么做。。。Plz帮助…

属性列表可以管理NSData,并且可以从NSData创建UIImage:

+ (UIImage *)imageWithData:(NSData *)data

但我不认为这是最好的办法。您可以保存图像文件并在plist中引用该文件。

您是在plist文件中存储图像数据还是图像名称?我强烈建议您将图像数据作为资源存储在捆绑包中。