Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8134413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:01:02+00:00 2026-06-06T10:01:02+00:00

I have a plist (array of dictionaries) which populates a table view and works

  • 0

I have a plist (array of dictionaries) which populates a table view and works properly. I use Xcode 4 with storyboards.

Now I’ve created a detail view from a regular UIViewController and of course I want the selected name to be displayed in the nameLabel in the detail view. But I can’t make the right connection. This is my code so far:

WineObject.m:

#import "WineObject.h"

@implementation WineObject 
@synthesize libraryContent, libraryPlist;

- (id)initWithLibraryName:(NSString *)libraryName {
    if (self = [super init]) {
        libraryPlist = libraryName;
        libraryContent = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] 
                                                              pathForResource:libraryPlist ofType:@"plist"]];
}
return self;
}


- (NSDictionary *)libraryItemAtIndex:(int)index {
return (libraryContent != nil && [libraryContent count] > 0 && index < [libraryContent count]) 
? [libraryContent objectAtIndex:index]
: nil;
}

- (int)libraryCount {
    return (libraryContent != nil) ? [libraryContent count] : 0;
}

- (void) dealloc {
    if (libraryContent) [libraryContent release];
    [super dealloc];
}

@end

ViewController.h:

#import <UIKit/UIKit.h>
@class WineObject;

@interface WinesViewController : UITableViewController {
WineObject *wine;
}


@end

ViewController.m:

#import "WinesViewController.h"
#import "WineObject.h"
#import "WineCell.h"

@interface WinesViewController ()

@end

@implementation WinesViewController

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - Table view data source

- (void)viewWillAppear:(BOOL)animated {
    wine = [[WineObject alloc] initWithLibraryName:@"Wine"];
    self.title = @"Vinene";
    [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [wine libraryCount];
}

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

    WineCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    // Configure the cell...

    cell.nameLabel.text = [[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Name"];
    cell.districtLabel.text = [[wine libraryItemAtIndex:indexPath.row] valueForKey:@"District"];
    cell.countryLabel.text = [[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Country"];
    cell.bottleImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Image"]];
    cell.flagImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Flag"]];
    cell.fyldeImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Fylde"]];
    cell.friskhetImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Friskhet"]];
    cell.garvesyreImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Garvesyre"]];

    return cell;
}

#pragma mark - Table view delegate

@end

WineCell.h:

#import <UIKit/UIKit.h>

@interface WineCell : UITableViewCell

@property (nonatomic, strong) IBOutlet UILabel *nameLabel;
@property (nonatomic, strong) IBOutlet UILabel *districtLabel;
@property (nonatomic, strong) IBOutlet UILabel *countryLabel;
@property (nonatomic, strong) IBOutlet UIImageView *bottleImageView;
@property (nonatomic, strong) IBOutlet UIImageView *flagImageView;
@property (nonatomic, strong) IBOutlet UIImageView *fyldeImageView;
@property (nonatomic, strong) IBOutlet UIImageView *friskhetImageView;
@property (nonatomic, strong) IBOutlet UIImageView *garvesyreImageView;

@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:01:03+00:00Added an answer on June 6, 2026 at 10:01 am

    Are you using a XIB for interface or generating it programmatically?


    If you are using a XIB, the issue is that you aren’t loading it up:

    Change

    winesDetailViewController = [[WinesDetailViewController alloc] init];

    To

    winesDetailViewController = [[WinesDetailViewController alloc] initWithNibName:@"YourNibNameHere" bundle:nil];


    Or, if you are generating it programmatically, you must first set nameLabel or it will be nil. @synthesize doesn’t set the variable, it simply generates getters and setters so that you can set it from outside.

    Inside your viewDidAppear: (or better yet inside your init) add:

    self.nameLabel=[[UILabel alloc] initWithFrame:CGRectMake(100,100,100,100)];


    EDIT: If you are using Storyboards, it appears that you have to do the following.

    Storyboards are all about relationships. Inside the story board editor, you add buttons and tell them which view controller they connect to. The same idea applies to TableView Cells. You can add a prototype table view cell (and customize it) and assign a relationship to it. The relationship you will want to give it is your detail view.

    1.) Subclass UITableViewCell and give it a property that is the dictionary that you are trying to send to the detail view

    2.) When creating cells (cellForRowAtIndexPath:) you will need to make sure to dequeue your custom cell and assign your dictionary to the property that you gave it.

    3.) Make sure that your detail view has the identifier: DetailView

    4.) Inside the table view controller, add the following code:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
       if([segue.identifier isEqualToString:@"DetailView"])
       {
          //This works because by the time prepareForSeque: is called, the navigationController has loaded the new view
          ((DetailView *)[[self.navigationController viewControllers] objectAtIndex:0]).dataProperty=((MyCustomTableViewCell *)sender).dataProperty;
       }
    }
    

    That ought to do it!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a plist file which is an array of dictionaries. Where each dictionary
I have a plist file which contains an array of dictionaries. Here is one
I have created a plist file which contain a single array which contains four
I have a plist which contains an array of NSDictionary 's which represent a
I have an array of dictionaries loaded from a plist (below) called arrayHistory. <plist
If I have a plist which is structured like this: Root Array Item 0
If I have a plist which I have put into and array, which looks
I have a custom plist file which contains dictionaries. Each dictionary contains information about
I have an array of dictionaries in an iOS .plist structured similar to the
I have a plist which is an array, the file name is called startups.plist.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.