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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:44:24+00:00 2026-05-27T21:44:24+00:00

In a tab-based app when I switch between some tabs, I sometimes get EXC_BAD_ACCESS

  • 0

In a tab-based app when I switch between some tabs, I sometimes get EXC_BAD_ACCESS. It’s not every time but if you flick back and forward a few times it eventually happens.

Defined in the .h:

NSUserDefaults *theData;

I’ve got this in viewWillAppear and viewWillDisappear:

[theData synchronize];

The line at fault gets called in a function at the viewWillAppear stage:

NSMutableArray *thisArray = [theData objectForKey:@"FriendsArray"];

I’m using NSUserDefaults to store a few dictionaries of data. This is populated by server calls, but there’s no need for an internal database due to it being refreshed often. I am open to other ways of storing this data if that would be better.

I have tried a number of things like casting it (NSMutableArray *)[theData objectForKey:@"FriendsArray"]; or using arrayForKey and a number of other things with no improvement.

Any help or tips would be greatly appreciated.

  • 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-27T21:44:24+00:00Added an answer on May 27, 2026 at 9:44 pm
    NSMutableArray *thisArray = [theData objectForKey:@"FriendsArray"]; // retain
    

    The way you try to make an array mutable is wrong. Also written like that, as suggested in the comments, you should probably retain that array.

    Try init/alloc a new mutable array with objects like this :

    NSMutableArray *thisArray =
     [[NSMutableArray alloc] initWithArray:[theData objectForKey:@"FriendsArray"]];
    

    Another method, -(id)initWithArray:(NSArray *)array copyItems:(BOOL)flag;, allows you to make a copy of the original objects.

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

Sidebar

Related Questions

I have an UITabBar based iPhone app with 4 different UIWebViews under every tab.
I'm developing an iPhone app that features a tab-bar based navigation with five tabs.
I have a view based app (not navigation or tab based...) My main view
I have a tab-based Android app. Currently, it does not support landscape mode -
I built a very simple tab based app with 2 tabs, each tab tied
I'm writing a tab-based universal app where one of the tabs takes considerably much
a tab bar based app with 5 tabs switching option...how i am suppose to
I have a tabbar-based iOS app with two tabs. When I tab into the
I have a tab-based iPhone app where I want to increase the perceived start-up
I am working on a simple app tab-bar based application that has two views.

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.