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 7989315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:43:20+00:00 2026-06-04T12:43:20+00:00

So I have an application that have a tab in tab bar that display

  • 0

So I have an application that have a tab in tab bar that display my TableView. Recently I modified it, and change my path for table from default
NSString *path = [[NSBundle mainBundle]pathForResource:@"Food" ofType"plist"];

replacing it with this:
NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject]stringByAppendingString:@"food.plist"];

So my problem is, it work pretty fine when I am launching it on Simulator in XCode, but, when im trying to launch it on my iphone I cant see any TableView appear, just empty search bar and top navigation bar.

- (void)viewDidLoad {
    [super viewDidLoad];

    NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject]stringByAppendingString:@"food.plist"];
    listOfItems = [[NSMutableArray alloc]initWithContentsOfFile:path];
    searchListOfItems = [[NSMutableArray alloc]init];

    searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 45)];
    searchBar.barStyle = UIBarStyleBlackTranslucent;
    searchBar.showsCancelButton = NO;
    searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
    searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
    searchBar.delegate = self; 
    [[self tableView] setTableHeaderView:searchBar];

    searching = NO;
    letUserSelectRow = YES;
    UIBarButtonItem *addButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addProduct:)];
    self.navigationItem.rightBarButtonItem = addButton;

    [self.tableView reloadData]; 
}

- (void)hideModalViewController:(NSNotification *)notif {
    [self dismissModalViewControllerAnimated:YES];
    [self viewDidLoad];
}
- (void)addProduct:(UIBarButtonItem *)button {
    BIDAddProductViewController *addProductVC = [[BIDAddProductViewController alloc]init];
    [self presentModalViewController:addProductVC animated:YES];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(hideModalViewController:) name:@"HideModalViewController" object:addProductVC];
}
- (void)viewDidUnload {
    [super viewDidUnload];
    self.childController = nil;
    self.tableView = nil;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        NSLog(@"Delete");
        NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject]stringByAppendingString:@"food.plist"];
        NSMutableArray *listOfItemsToDelete = [[NSMutableArray alloc]initWithContentsOfFile:path];

        [[[listOfItemsToDelete objectAtIndex:indexPath.section]objectForKey:@"Products"] removeObjectAtIndex:indexPath.row];
        [listOfItemsToDelete writeToFile:path atomically:YES];
        [self viewDidLoad];
    }
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewCellEditingStyleDelete;
}

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *SectionsTableIdentifier = @"SectionsTableIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SectionsTableIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:SectionsTableIdentifier];
    }

    if(searching)
        cell.textLabel.text = [[searchListOfItems objectAtIndex:indexPath.row]valueForKey:@"ProductName"];
    else {
        NSDictionary *dictionary = [listOfItems objectAtIndex:indexPath.section];
         NSArray *array = [[dictionary objectForKey:@"Products"]valueForKeyPath:@"ProductName"];
        NSString *cellValue = [array objectAtIndex:indexPath.row];
        cell.textLabel.text = cellValue;
    }
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
    return cell;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    if (searching)
        return 1;
    else
        return [listOfItems count];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (searching)
        return [searchListOfItems count];
    else {
        NSDictionary *dictionary = [listOfItems objectAtIndex:section];
        NSArray *array = [dictionary objectForKey:@"Products"];
        return [array count];
    }
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    if(searching)
        return @"";
   return [[listOfItems objectAtIndex:section]valueForKey:@"SectionName"];
}

@end

I want to mention that I did some things with Project and Target settings, but, before that issue everything was just fine. I have an iPhone 4s if thats matter. And I did cut lot of my code rows just for make it easier to read (removed searching methods and selecting row methods).

Please help me!

  • 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-04T12:43:22+00:00Added an answer on June 4, 2026 at 12:43 pm

    I think the problem is with –

    NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject]stringByAppendingString:@"food.plist"];
    

    you need to use –

    NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject]stringByAppendingPathComponent:@"food.plist"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table view in an iPhone xcode tab bar application that shows
I have a tab bar application and I want to display those views that
In my application i have Tab bar Controller. I want to change default color
Within my iPhone application I have a common tab bar with three tabs that
I have a tab bar application that contains navigation views in 2 of its
I have an application that uses a tab bar and whenever it launches it
I have an application that has 4 views that are toggled by Tab Bar
I have an application that has many views (Using tab bar controller). I want
I have a tab bar in my application and that how I am customizing
I have an application with several view controllers controlled from a tab bar controller.

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.