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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:44:42+00:00 2026-06-13T07:44:42+00:00

I have a NSMUtableArray and a NSMutableDictionary . My code gets objects from an

  • 0

I have a NSMUtableArray and a NSMutableDictionary. My code gets objects from an NSArray into a NSMUtableDictionary. Then add those NSMUtableDictionary objects into an NSMutableArray

this is my code

`

  NSArray *sqlAllarray=[[NSArray alloc]initWithArray:[sqlite executeQuery:@"SELECT * FROM dir_bill"]];

    for (NSMutableDictionary *alldataDict in sqlAllarray ) {

        paydate2=[fmtDate2 dateFromString:[alldataDict valueForKey:@"bill_dateDue"]];

        if ([paydate1 compare:paydate2]==NSOrderedDescending || [paydate2 compare:paydate1]==NSOrderedSame) {


            appDel.untillPaydayArray=[[NSMutableArray alloc]init];//addObject:[alldataDict copy]];
            [appDel.untillPaydayArray addObject:[alldataDict copy]];
        }

    }`

But it takes only the last NSMUtableDictionary data into the NSMUtableArray. How can I solve this problem.

Thanks

  • 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-13T07:44:44+00:00Added an answer on June 13, 2026 at 7:44 am

    You are creating a new mutable array during every iteration of the loop. There are a few other issues in this code. Try this:

    1. NSArray *sqlAllarray = [sqlite executeQuery:@"SELECT * FROM dir_bill"];
    
    2. appDel.untillPaydayArray = [[NSMutableArray alloc] init];
    
    3. for (NSMutableDictionary *alldataDict in sqlAllarray ) {
    4.    paydate2=[fmtDate2 dateFromString:[alldataDict valueForKey:@"bill_dateDue"]];
    
    5.    if ([paydate1 compare:paydate2] == NSOrderedAscending) {
    6.        [appDel.untillPaydayArray addObject:[alldataDict copy]];
    7.    }
    8.}
    

    1) No need for the extra NSArray creation.

    2) You need to initialize the array once, before the loop. You had this in the loop so each iteration resulted in the array being reset.

    5) No need to check for descending and equal. Just check for ascending.

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

Sidebar

Related Questions

I have a simple code: NSMutableArray *arrayCheckList = [[NSMutableArray alloc] init]; [arrayCheckList addObject:[NSMutableDictionary dictionaryWithObjects:[NSArray
I have a NSMutableArray (tripHistory) that gets a NSMutableDictionary (currentUpdate) added to it every
Got this code in my controllers (void)viewDidLoad method self.purchasesPerClassification = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@Moo,nil] forKeys:[NSArray
My codes: NSArray *array = //objects here NSMutableArray *mutarray = [[NSMutableArray alloc] init]; for
I have added several class Objects into a NSMutableArray . It seems to have
If I have a mutable array codes in an NSMutableDictionary categorize NSMutableArray *myMutableArray=(NSMutableArray*)[categorize objectForKey:@codes];
I have a NSMutableArray and it has the users high scores saved into it.
I have an NSMutableArray which has five objects in it. I want to insert
I have a NSMutableArray called putNumberUsed. It contains the following objects @blah1,@blah2,@blah3,@blah4. I want
I have an NSMutableArray which I assign with: NSMutableArray *newElements = [[NSMutableArray alloc] initWithObjects:self.currentScene.elements,

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.