Paul A.
Paul A.

Reputation: 597

IOS 5: Using Asset Object loaded in UITableView to display in another ViewController using StoryBoard

Edited:

From my earlier question (below), I have a handle on my assets (video) and I also have an implementation of my PlayVideoViewController but I am stuck on how to pass this asset to the playVideoViewController object. Here is a code snippet of the implementation:

.... }

In my line 1., it gives me a "Use of undeclared identifier 'asset'" error. If I can pass 'asset' then I can resolve the issue but the only examples I have seen use .nib not storyboard so for example, using .NIB, the call is: PlayVideoViewController *playVideoViewController = [[PlayVideoViewController alloc ] initWithNibName:@"PlayVideoViewController" bundle:nil asset:asset]; Please help on how to pass the 'asset'.

==

I can't figure out just one thing and I hope someone can help me out. Please note I am not using a .nib but storyboards and that is why I am stuck here.

I have loaded assets (videos) into a tableview and when a user selects a tableviewcell, the app transitions to a new view controller (PlayVideoViewController) that just plays the video. From the class loading the asset (*asset) and letting the user select it, I have this code snippet:

ALAsset *asset = [assets objectAtIndex:row];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard.storyboard" bundle:nil];

PlayVideoViewController *playVideoViewController = [storyboard instantiateViewControllerWithIdentifier:@"PlayVideoViewController"];     
[self.navigationController pushViewController:playVideoViewController animated:YES ];

How do I pass the selected video to PlayVideoViewController so it just plays the video? How so I incorporate that into my code and kindly show me an example?

Upvotes: 1

Views: 261

Answers (2)

Paul A.
Paul A.

Reputation: 597

This might help someone else: in order to resolve the issue, I simply created an ALAsset object in the new viewcontroller and passed the object to it after storyBoard:instantiateViewControllerWithIdentifier.

Upvotes: 0

Michael Dautermann
Michael Dautermann

Reputation: 89509

Create a "@property" in your PlayVideoViewController's ".h" (interface) file that takes a file URL or some way to reference your video.

Then, after you instantiate your playVideoViewController and before you push, simply set that property's value to the file URL so your new controller knows where to get the video from.

Upvotes: 0

Related Questions