Passing movie title to a detail view in ios

I am able to parse a json file to a tableview but I can't figure out how to get the movie title and pass to my detail view as the title. Below is my methods

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"movieCell";

    movieCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    id video = [self.model.videos objectAtIndex:indexPath.row];
    NSString *rl = [video objectForKey:@"release_date"];
    NSString *imageURL;
    if ([[video objectForKey:@"poster_path"] class] != [NSNull class])
        imageURL = [video objectForKey:@"poster_path"];
    else
        imageURL = @"icon.jpg";

    if (rl != (NSString *)[NSNull null]){
            NSString *dateStr = rl;
            // Convert string to date object
            NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
            [dateFormat setDateFormat:@"yyyy-MM-dd"];
            NSDate *date = [dateFormat dateFromString:dateStr];

            // Convert date object to desired output format
            [dateFormat setDateFormat:@"MM/YYYY"];
            NSString *released = @"Released: ";
            NSString *fullDate;
            dateStr = [dateFormat stringFromDate:date];
            fullDate = [NSString stringWithFormat:@"%@ %@", released, dateStr];
            cell.videoDescriptionLabel.text = fullDate;
    }
    else{
        cell.videoDescriptionLabel.text = @"N/A";
    }
    cell.videoTitleLabel.text = [video objectForKey:@"title"];      
    NSString* thumbnailURL = [NSString stringWithFormat:@"http://cf2.imgobject.com/t/p/w154%@",imageURL];
    [cell.videoThumbnail setImageWithURL:[NSURL URLWithString:thumbnailURL] placeholderImage:[UIImage imageNamed:@"icon"]];
    return cell;
}

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    DetailViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"boot"];
    [self.navigationController pushViewController:vc animated:YES];

}

Answers


id video = [self.model.videos objectAtIndex:indexPath.row];
vc.title = [video objectForKey:@"title"];

Btw, you shouldn't use id as the type of video above.


Assuming that you have a property called videoTitle within your DetailViewController like this

@property (nonatomic, strong) NSString *videoTitle;

Then you'd just do:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    DetailViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"boot"];
    vc.videoTitle = [[self.model.videos objectAtIndex:indexPath.row] objectForKey:@"title"];
    [self.navigationController pushViewController:vc animated:YES];
}

Need Your Help

What's wrong with creating sequence id hibernate generator?

spring hibernate jpa sequence

I want to use sequence id generator,that will work in all databases.So i was seacrhing for an answer and found that blog and according to this next snippet must work:

PHP GET variable `/` instead of `?`

php variables get

I'm working with a script that doesn't allow $_GET[] variables in the URL (it's a referrer url I'm giving out and I need to have some way to track it). I can't have this for example

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.