0

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
Daljeet
  • 1,573
  • 2
  • 20
  • 40
  • You are assigning the value but not loading the VC. Are you using segue? – Yogesh Suthar Jul 18 '14 at 09:46
  • Hi Yogesh,i'm not using any seague,in split view controller master and detail view controller both contain uitableview,detail view is load by url now i want to pass different urls on click on different cells in master view controller. – Daljeet Jul 18 '14 at 09:52
  • Try this http://stackoverflow.com/questions/10019422/passing-values-between-master-and-detail-in-uisplitviewcontroller-using-storyboa – Yogesh Suthar Jul 18 '14 at 09:55
  • Unrelated to your question, but read Apple's guidelines on naming conventions; class names should always start with a capital letter, not a small one. (: – Neeku Jul 18 '14 at 09:56
  • thanks @Neeku :),to mention this point.Could you help me to solve my problem. – Daljeet Jul 18 '14 at 10:01

2 Answers2

0

You can get SplitViewController from masterViewController by self.splitViewController Then you can get detailViewController as

  DetailViewController *detailViewController = (DetailViewController*)self.splitViewController.viewControllers[1];

  detailViewController.url = yourURL;
Suhail kalathil
  • 2,673
  • 1
  • 13
  • 12
0

Try creating a ysDetail Object, then creating a method with your ysDetail class that is a getter for the Url.

-(void)getUrl:(NSURL)url;

and to create an object:

@Property ysDetail *detailClass;
Divya Bhaloidiya
  • 5,018
  • 2
  • 25
  • 45
objectively C
  • 960
  • 9
  • 25