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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:46:59+00:00 2026-05-26T09:46:59+00:00

In my app I have a UITableViewCobtroller which creates the table view with checkmark

  • 0

In my app I have a UITableViewCobtroller which creates the table view with checkmark accessory type. Table View loads and works correctly. In didSelectRowAtIndex method I wrote method of adding data in sqlite dataBase:

        [self.dataBaseController openSettingsDB];
        [self.dataBaseController updateRecordIntoTableNamed:kTableName withField:kSField1Name fieldValue:newCell.textLabel.text];
        [self.dataBaseController closeDB];

It works well. So what I want is to retrieve the recorded data from dataBase and when the application is relaunched to select the row, that has the title, that I retrieved from sqlite dataBase.

I tried this:

-(void)viewDidLoad
{
    NSArray *array = [[NSArray alloc] initWithObjects:
                      kCourse1, kCourse2, kCourse3, kCourse4, kCourse5, kCourse6, nil];
    self.list = array;
    [self.dataBaseController openSettingsDB];
    [self.dataBaseController getRowFromTableNamed:kTableName whichRow:kSField1Name];
    self.chosenStr = self.dataBaseController.dataString;
    [lastIndexPath indexAtPosition:[array indexOfObjectIdenticalTo:self.chosenStr]];
    UITableViewCell *cell = [[UITableViewCell alloc] init];
    cell = [self.tableView cellForRowAtIndexPath:lastIndexPath];
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
    [self.tableView reloadData];
    [array release];
    [super viewDidLoad];
}

But it doesn’t work. Please, suggest me any ideas. Thanks in advance.

Alick

  • 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-05-26T09:46:59+00:00Added an answer on May 26, 2026 at 9:46 am

    Updated Answer:

    You should not be doing this in viewdidLoad in the first place. Its a bad practice, you should do it in cellForRowAtIndexPath:.

    More explaination:

    The table is not loaded as of yet in viewDidLoad. You have to do [self.tableView reloadData]; before doing anything else. Doing that will call the delegate methods for table (it has no idea how many cells there are so getting the cell for any specfic index path doesn’t make sense). See Table View Programming guide.

    Also:

    UITableViewCell *cell = [[UITableViewCell alloc] init];
    cell = [self.tableView cellForRowAtIndexPath:lastIndexPath];
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
    

    First, this is wrong. You are leaking memory with that alloc/init. Just do:

    UITableViewCell *cell = nil;
    cell = [self.tableView cellForRowAtIndexPath:lastIndexPath];
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an edit view in my app which is a instance of UITableViewController
I have a UITableViewController in my app, which is added to the view hierarchy
In my app, I have a UITableViewController which loads calculated data from my Core
I have a UIViewController which has a table view and a date picker view.
I have a Tab bar App with four tabs. Each tab loads the same
I'm writing an iOS app with a table view inside a tab view. In
I have an App Delegate and a 3 view controllers in my project. I
I have an app with a UITabBarController that manages some UINavigationControllers, which in turn
I have a CoreData app with the MainView the UITableViewController which houses all of
In my Universal app which supports IOS4 and later, I have a UINavigationController and

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.