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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:58:56+00:00 2026-06-09T20:58:56+00:00

NSMutableArray *tmpMutArr = [NSMutableArray arrayWithArray:allObjectsArray]; NSLog(@The content of array is%@,tmpMutArr); int index; for (int

  • 0
    NSMutableArray *tmpMutArr = [NSMutableArray arrayWithArray:allObjectsArray];
    NSLog(@"The content of array is%@",tmpMutArr);

    int index;

     for (int i=0;i<[tmpMutArr count];i++) 
     {
     if([[tmpMutArr  objectAtIndex:i] isKindOfClass:[NSDictionary class]])
     {
     NSMutableDictionary *tempDict = [tmpMutArr  objectAtIndex:i];
         if([[tempDict valueForKey:@"Name"] isEqualToString:[NSString stringWithFormat:@"%@", nameString]])
     {
     index = i;

     }
     }
     }

     [tmpMutArr replaceObjectAtIndex:index withObject:[NSDictionary dictionaryWithDictionary:mutDict]];

This code is not replacing the matching object in tmpMutArr as I want it to, but replaces all objects in tmpMutArr instead. How to replace only the index I want?

I know that tmpMutArr containing all objects before the replacement, so I just need to specify the index correctly I think. How to do so?

  • 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-09T20:58:57+00:00Added an answer on June 9, 2026 at 8:58 pm
    NSMutableArray *tmpMutArr = [NSMutableArray arrayWithArray:allObjectsArray];
    NSLog(@"The content of array is%@",tmpMutArr);
    
    int index;
    
    for (int i=0;i<[tmpMutArr count];i++) 
    {
        if([[tmpMutArr  objectAtIndex:i] isKindOfClass:[NSDictionary class]])
        {
            NSMutableDictionary *tempDict = [tmpMutArr  objectAtIndex:i];
            if([[tempDict valueForKey:@"Name"] isEqualToString:nameString])
            {
                index = i;
                break; // << added break
            }
        }
    }
    
    [tmpMutArr replaceObjectAtIndex:index withObject:[NSDictionary dictionaryWithDictionary:mutDict]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

NSMutableArray *arr = [NSMutableArray arrayWithCapacity:3]; if ([arr isMemberOfClass:[NSMutableArray class]]) { NSLog(@YEP!!); } else {
I'm using a NSMutableArray *allObjectsArray; with dictionaries to fill a Table View with content.
-(NSMutableArray*) fetchMakeNamesYear1:(int) year1 Year2:(int) year2 compileStaement: (sqlite3_stmt*)compiledStatement { NSMutableArray *makeNames=[NSMutableArray array]; NSString *selectQuery=[NSString stringWithFormat:@SELECT
NSMutableArray *array = [[NSArray alloc] initWithObjects:@Apranax Forte, @Actified, @Zostex 125 MG, @Zoprotec 30 MG,
-(NSMutableArray *)processResult:(NSArray*)matchArray removeString:(NSString *)removeStr{ NSString *newLink; NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:[matchArray count]]; //doing
I have NSMutableArray day which contain (6 NSMutable arrays) arrays contain class Lesson{ NSString
I have some NSMutableArray in tableView which contain class Lesson @interface Lesson : NSObject
I have an NSMutableArray of custom objects. The custom object (Tag Class) has an
I have an NSMutableArray that contains many NSArrays. At a specific (static) index in
NSMutableArray*array = [[NSMutableArray alloc]init]; NSArray*Somearray = [NSArray arrayWithObjects:1st Object,2ndObject,3rd Object,4th object,5th Object,nil]; In the

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.