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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:37:14+00:00 2026-05-22T11:37:14+00:00

I am sending an update for my app that will require that the users

  • 0

I am sending an update for my app that will require that the users databases be updated. I am storing data in a property list. Basically a every point in the array are NSMutableDictionaries and I need to add keys, replace keys etc.

I attempted the following, however it generates an NSException,

for (NSMutableDictionary *dict in myArray) {

    if ([dict objectForKey:@"someKey"] == nil) {

        //Extract the value of the old key and remove the old key
        int oldValue = [[dict objectForKey:@"key1"] intValue];
        [dict removeObjectForKey:@"key1"];

        [dict setValue:[NSString stringWithFormat:@"%d pts", oldValue] forKey:@"newKey"];

        //Add new keys to dictionnary
        [dict setValue:@"some value" forKey:@"key2"];
        [dict setValue:@"some value" forKey:@"key3"];
        [dict setValue:@"some value" forKey:@"key4"];

        [self.myArray replaceObjectAtIndex:index withObject:dict];

    }

What should I do to update my data in the above manner?

  • 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-22T11:37:14+00:00Added an answer on May 22, 2026 at 11:37 am

    The problem is that you cannot modify the array you are iterating over with fast enumeration.

    The code snippet has no need for that replaceObjectAtIndex:withObject: call at all, as you replace the object with the very same object! So if you remove that line everything should work.

    Generally, you can avoid similar problems if you use the plain old for loop with indexing, i.e.

    for (int i = 0; i < [array count]; i++) {
        id obj = [array objectAtIndex:i];
        // ...
    }
    

    as this will not mess up with fast enumeration.

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

Sidebar

Related Questions

I am trying to write a basic app that will read data off a
I'm looking into sending regular automated text-messages to a list of subscribed users. Having
i have a design issue regarding sending user data from a mobile phone app
I have a Silveright app that allows users to specify filters on a few
I'm creating an android app that is exchanging data with a web app via
I am creating an app that needs to be able to receive data at
I'm trying to send and receive binary data sms from my app (sdk 2.1-update
In a company I work for we have an app that shows TV-programs. Users
I'm in the early stages of writing an app that will need to broadcast
I'm building an app where my users will post content. The exact time of

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.