Reputation: 59
I have the 3 methods below using storyboard where I have a "segue" connect from my "View Movie Info" button to my next view. The identifier is "web"
When I click on the button I call this method: (IBAction)synopsis:(id)sender then this method calls -> (void)fetcheMovie:(NSData *)responseData and then it should go to (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)jason
On the prepareforsegue method I put a nsslog on the "jsonSendetAsParamInPerformSegue" and I get two logs
1: UIRoundedRectButton: 0x9595c60; frame = (11 322; 298 44); opaque = NO; autoresize = TM+BM; layer = CALayer: 0x9595d30
2->My json results ( what I expect )
and below i get this: 2013-05-09 18:55:06.185 drigo[840:c07] nested push animation can result in corrupted navigation bar Unbalanced calls to begin/end appearance transitions for . Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
I need to get one of the values from the json and pass it to my next view
The methods are below.. Please help.. I've been stuck for couple of days on this
- (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];
news = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
[self performSegueWithIdentifier:@"web" sender:news];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)jason {
NSError* error;
NSDictionary *jsonSendetAsParamInPerformSegue = (NSDictionary*)jason;
NSLog(@"%@",jsonSendetAsParamInPerformSegue);
//WebViewController *targetVC = (WebViewController*)segue.destinationViewController;
//targetVC.newsArticles = jsonSendetAsParamInPerformSegue;
}
Upvotes: 0
Views: 402
Reputation: 1019
You should connect the segue from the source ViewController to the destination ViewController, don't connect it from the button.
If you connect it from the button, when you click the button, it performs the segue(the sender is the button), then in your code you call perform segue again, that is why it's wrong.
Upvotes: 1