2012-04-28 22 views
1

私は辞書付きのplistを持っています。
辞書には、画像のURLアドレスを持つ "cellPic"という文字列があります。
私はドロップボックスアカウント&にplist文字列で読み取った画像をテーブルビューに取り込もうとしています。
(「arrayFromPlistは」私の配列である)
問題は、私はそれを実行したとき、私はコンソールでエラーになってるということです。
[__NSCFDictionary objectAtIndex:]:認識されていないセレクタplist文字列からURLイメージを読み取る

これは私のコードです:

-(void) readPlistFromDocs 
{ 
    // Path to the plist (in the Docs) 
    NSString *rootPath = 
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0]; 
    NSString *plistPath = [rootPath stringByAppendingPathComponent:@"Data.plist"]; 
    NSLog(@"plistPath = %@",plistPath); 
    // Build the array from the plist 
    NSMutableArray *arrayFromDocs = [[NSMutableArray alloc] initWithContentsOfFile:plistPath]; 
if (arrayFromDocs) 
{ 
    NSLog(@"\n content of plist file from the documents \n"); 
    NSLog(@"Array from Docs count = : %d", [arrayFromDocs count]); 
} 
    arrayFromPlist = [[NSArray alloc] initWithArray:arrayFromDocs]; 
} 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return 1; 
} 

// Returns the number of rows in a given section. 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return [arrayFromPlist count]; 
    NSLog(@"Array SIZE = %d",[arrayFromPlist count]); 
} 

- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) 
{ 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
} 

NSURL *url = [[NSURL alloc] initWithString:[[arrayFromPlist objectAtIndex:indexPath.row] objectForKey:@"cellPic"]]; 
NSData *urlData = [[NSData alloc] initWithContentsOfURL:url]; 
[[cell imageView] setImage:[UIImage imageWithData:urlData]]; 

return cell; 
} 

私の他の質問は、 - 私はplist文字列からURLを読むときに画像を非同期に読み込むことができますか?
私はそれのための例を見つけようとしましたが、私はplistなしで非同期しか見つけませんでした。
ありがとうございます。

答えて

関連する問題