我有一个函数,在这个函数中,我从其他视图控制器中定义的字典调用值。我必须在当前视图控制器的view didload方法中调用此方法。
下面是我的代码:
-(void)setData:(NSDictionary *)dic {
self.jsonLabel.text = [dic objectForKey:@"Description"];
self.jsonImage.image = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: [dic objectForKey:@"PictureURL"]]]];}发布于 2011-03-10 18:06:07
我在其他的视图控制器中使用了这段代码
并尝试在currentViewController中检索
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
JSONViewController *controller = [[JSONViewController alloc] initWithNibName:@"JSONView" bundle:nil];
EmpDictionary=[[NSMutableDictionary alloc]init];
[EmpDictionary setValue:aBook.Description forKey:@"Description"];
[EmpDictionary setValue:aBook.PictureURL forKey:@"PictureURL"];
[EmpDictionary setValue:aBook.WeatherID forKey:@"WeatherID"];
EmpArray=[[NSMutableArray alloc]init];
[EmpArray addObject:EmpDictionary];
NSDictionary *itemAtIndex = [self.EmpArray objectAtIndex:indexPath.row];
[self.navigationController pushViewController:controller animated:YES];
[controller setData:itemAtIndex];}https://stackoverflow.com/questions/5257751
复制相似问题