Note that there are some explanatory texts on larger screens.

plurals
  1. POPopulating Plist to UITableView,Stored in Document Directory
    primarykey
    data
    text
    <p>I have plist stored in the <code>Document Directory</code>,how to call in <code>UITableView</code> if it stored in Document Directory</p> <p><img src="https://i.imgur.com/JKoT8.png" alt="eneter image"> . This is how I read from the plist.</p> <p>In <code>ViewDidLoad</code></p> <pre><code>- (void)viewDidLoad { NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [documentPaths objectAtIndex:0]; NSString *documentPlistPath = [documentsDirectory stringByAppendingPathComponent:@"p.plist"]; NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:documentPlistPath]; NSArray *valueArray = [dict objectForKey:@"title"]; self.mySections = valueArray; [super viewDidLoad]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { //Return the number of sections. return [self.mySections count]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. NSString *key = [self.mySections objectAtIndex:section]; NSArray *dataInSection = [self.myData objectForKey:key]; return [dataInSection count]; } -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { NSString *key = [self.mySections objectAtIndex:section]; return [NSString stringWithFormat:@"%@", key]; } -(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { return self.mySections; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] ; } // Configure the cell... NSUInteger section = [indexPath section]; NSUInteger row = [indexPath row]; NSString *key = [self.mySections objectAtIndex:section]; NSDictionary *dataForSection = [[self.myData objectForKey:key] objectAtIndex:0]; NSArray *array=dataForSection.allKeys; cell.textLabel.text = [[dataForSection allKeys] objectAtIndex:row]; cell.detailTextLabel.text=[dataForSection valueForKey:[array objectAtIndex:indexPath.row]]; return cell; } </code></pre> <p><strong>EDIT</strong> when i <code>NSlog</code> <code>valueArray</code> output is <code>( { pass = tryrt; title = tyr; }, { pass = tryrt; title = tyr; }, { pass = tryrt; title = tyr; }, { pass = tryrt546546; title = tyr; } )</code></p> <p>that means problem is in</p> <p><code>cellForRowAtIndexPath</code></p>
    singulars
    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