I'm building an article-reading iOS app. In iPad I'm using split view controller and I want to update detail view controller on tapping different cells in master view controller by passing different URLs.
I am unable to pass NSURL
form one class to another to load detail view controller(UITableView)
ysMaster.h
:
@property (strong, nonatomic) NSURL *ysURL;
ysMaster.m:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.row)
{
case 0:
[self performSegueWithIdentifier:@"Show1" sender:self];
_ysURL = [NSString stringWithFormat:@"http://you.com/234234"];
break;
case 1:
[self performSegueWithIdentifier:@"Show2" sender:self];
_ysURL=[NSURL URLWithString:@"http://goal.com/99099"];
break;
case 2:
[self performSegueWithIdentifier:@"Show3" sender:self];
_ysURL=[NSURL URLWithString:@"http://gggg.com/99099"];
break;
}
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(NSString *)sender{
if ([segue.identifier isEqualToString:@"Show1"])
{
ysDetail *dest = segue.destinationViewController;
dest.ysURL=sender;
}
if ([segue.identifier isEqualToString:@"Show2"])
{
ysDetail *dest = segue.destinationViewController;
dest.ysURL=sender;
[dest setURL:_ysURL];
}
if ([segue.identifier isEqualToString:@"Show3"])
{
ysDetail *dest = segue.destinationViewController;
dest.ysURL=sender;
}
}
ysDetail.h:
@property (strong, nonatomic) NSURL *url;
ysDetail.m:
NSData* data = [NSData dataWithContentsOfURL:_url];
NSLog(@"uuuuuuuuu%@",_url); //url prints null