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

  • Home
  • SEARCH
  • 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 8180165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:09:26+00:00 2026-06-07T00:09:26+00:00

For example, i got a method like this: – (void)addToRecents:(NSDictionary *)photo { NSUserDefaults *defaults

  • 0

For example, i got a method like this:

- (void)addToRecents:(NSDictionary *)photo
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSMutableArray *recents = [[defaults objectForKey:@"RecentPhotos"] mutableCopy];
    if(!recents) recents = [NSMutableArray array];
    [recents addObject:photo];
    [defaults setObject:recents forKey:@"RecentPhotos"];
    [defaults synchronize];
    self.recentPhotos = [[NSUserDefaults standardUserDefaults] objectForKey:@"RecentPhotos"];    
    [self.tableView reloadData];
}

Then it always couldn’t show the tableview i want. I use the nslog to print something in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath to see if this method really got called. Then i found out it never got called.

  • 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-07T00:09:27+00:00Added an answer on June 7, 2026 at 12:09 am

    I did the above cause from my past experience in C or Java, i think the place where you do the setup or initialization doesn’t matter, as long as you just do it anywhere you want even in a method or function like these lines:

    self.recentPhotos = [[NSUserDefaults standardUserDefaults] objectForKey:@"RecentPhotos"];    
    [self.tableView reloadData];
    

    However it didn’t work at all. It took me about one hour to check every other stuff to figure it out cause i always thought i’m doing the right way like in Java.

    Then i tried to put them inside the viewDidLoad(), it worked. I watched the Stanford lectures about viewController lifecycle again and as Paul said: it’s better to do all the setup or initialization in the vieDidLoad(). Now I learn this difference.

    This is just my own experience from working on the assignment 4.

    Hope it would help others not waste too much time on this. Thanks

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

Sidebar

Related Questions

If I've got an image which look, for example, like this: 0101001 1101101 0101001
In this example I want to add a .loop({quantity},{sleepvalue}) to a method I got
For example I got this 2 table dbo.fc_states StateId Name 6316 Alberta 6317 British
I got the example in this link . I can't understand the addmove ,
thank you for looking i got this example from my book but i cant
I've got a CustomersModule.cs with the following Initialize() method: public void Initialize() { container.RegisterType<ICustomersRepository,
I have, for example, markup like this <div id=content> <p>Here is some wonderful text,
I've got a data schema like this: cp id te su 1 7 2
I've got models like this: class PledgeItem(models.Model): title = models.CharField(...) usd_amount = models.DecimalField(...) class
I have got a Database like this: users -id user_cars -user_id -car_id cars -id

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.