Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to enter a new view from a UITableViewCell? (when the table view gets its information from a .plist)
    primarykey
    data
    text
    <p>I want to make a new view appear when i press a table view cell. But i seem to have som problems because my table view cells gets thei information from a .plist file i made. Here is my code. PS: I am making this in Storyboard.</p> <p>ViewController.h:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface ViewController : UIViewController&lt;UITableViewDataSource, UITableViewDelegate&gt; @property (copy, nonatomic) NSDictionary *firstTableView; @property (copy, nonatomic) NSArray *firstTableViewKey; @end </code></pre> <p>ViewController.m:</p> <pre><code>#import "ViewController.h" static NSString *SectionsTableIdentifier = @"SectionsTableIdentifier"; @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UITableView *tableView = (id)[self.view viewWithTag:1]; [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:SectionsTableIdentifier]; NSString *path = [[NSBundle mainBundle] pathForResource:@"firstTableView" ofType:@"plist"]; self.firstTableView = [NSDictionary dictionaryWithContentsOfFile:path]; self.firstTableViewKey = [[self.firstTableView allKeys] sortedArrayUsingSelector:@selector(compare:)]; tableView.backgroundColor = [UIColor clearColor]; tableView.opaque = NO; tableView.backgroundView = nil; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - #pragma mark Table View Data Source Methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return [self.firstTableViewKey count]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ NSString *key = self.firstTableViewKey[section]; NSArray *nameSection = self.firstTableView[key]; return [nameSection count]; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ return self.firstTableViewKey[section]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SectionsTableIdentifier]; NSString *key = self.firstTableViewKey[indexPath.section]; NSArray *nameSection = self.firstTableView[key]; cell.textLabel.text = nameSection[indexPath.row]; return cell; } @end </code></pre> <p>Thanks for any kind of help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload