我已经在 my.h 文件上声明了在@property (nonatomic, copy) NSDictionary *newsArticle;
my.mi 上有以下方法:
- (IBAction)synopsis:(id)sender {
NSString *urlString = [NSString stringWithFormat:@"http://api.themoviedb.org/3/movie/%@?api_key=34eb86f3b94de2676e8d3007b5ce1993",movieid];
dispatch_async(kBgQueue, ^{
NSURL *url = [NSURL URLWithString:urlString];
NSData* data = [NSData dataWithContentsOfURL:url];
[self performSelectorOnMainThread:@selector(fetcheMovie:)withObject:data waitUntilDone:NO];
});
}
- (void)fetcheMovie:(NSData *)responseData {
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
newsArticle= [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
NSLog(@"data1 = %@",newsArticle);
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSLog(@"data2 = %@",newsArticle);
if ([[segue identifier] isEqualToString:@"web"]){
WebViewController *vc = [segue destinationViewController];
vc.imdbnumber=@"tt0105236rodrigo";
}
}
在 fetcheMovie 方法上,我可以获得 newsArticle 的值,但在 prepareForSegue 方法上却不能。
我需要做什么才能访问这些值?我需要访问值才能传递到下一个视图谢谢罗德里戈