I'm trying to build a simple App where users can choose a video from a tableViewController, which then loads a view that plays a video. My problem is transferring the URL of the video from the tableViewController to the viewController.
I followed this tutorial, and I am now trying to adapt the code to play videos instead of just show images
I am creating a viewController from a tableViewController like this:
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
wwfpViewController * DVC = [[wwfpViewController alloc] init];
NSIndexPath * path = [self.tableView indexPathForSelectedRow];
NSString * theVideoName = [videoNames objectAtIndex:path.row];
NSString * theVideoURL = [videoList objectAtIndex:path.row];
DVC.videoNum = path.row;
DVC.videoName = theVideoName;
DVC.videoURL = theVideoURL;
[DVC play];
}
The play message for this viewController is then fired, and when I NSLog from this message the videoURL is present and correct.
Then viewDidLoad is fired on this viewController, and at this point when I NSLog the videoURL it is returned as (null).
I'm declaring the videoURL like this:
@property (strong, nonatomic) NSString * videoURL;
So I have a few questions:
- Does a
viewControllerlose its properties whenviewDidLoadis fired? - Is there a better approach to sending properties to a
viewController? - Am I doing this completely wrong?
- And do I need to provide any more code?