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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:13:24+00:00 2026-06-18T00:13:24+00:00

In my app I’m using two NSMutableDictionaries. Lets call them basicDictionary and refreshDictionary. In

  • 0

In my app I’m using two NSMutableDictionaries. Lets call them basicDictionary and refreshDictionary.

In basicDictionary I have values, lets say

key:”1″ value:”2000″ photo:someUIImage //Lets say I want to track score of player
key:”2″ value:”1500″ photo:someUIImage2
key:”3″ value:”1500″ photo:someUIImage3
key:”4″ value:”1500″ photo:someUIImage4

key stands for player id and rest is pretty clear.

I do server api call every 20 sec to refresh score of players. Because I don’t want to load photo as well im using refresh call to bring me only player id and his actual score.

So every 20 secs I get data that I save in refreshDictionary. There are only ids and current score of that id.

refreshDictionary example:

key:”1″ value:”2500″
key:”2″ value:”2800″
key:”3″ value:”2700″

I update my tableView with new values. As you can see, I got data only for 3 players, because player 4 has deleted his profile. Now my question is, how do I update basicDictionary to remove player 4?

I know that I’m supposed tu use if (!([basicDictionary isEqualToDictionary:refreshDictionary))
however, it won’t tell me at which key they aren’t equal.

So what would you guys do? Should I iterate through both of them in nested loop? That seems to consume alot of time when dictionaries are bigger. Oh by the way, my dictionaries are always sorted same way (by players id)

My idea is, that I compare these two dictionaries in

    - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
        if (refresh)
        { //compare dictionaries and modify basicDictionary that is data source for my tableview by deleting where key doesn't match
}
  • 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-18T00:13:26+00:00Added an answer on June 18, 2026 at 12:13 am

    this code will give you keys that changed:

    NOTE: as the lookup of keys is basically jumping into a hashmap (an o1 op), you dont have to worry about the 2nd array walk you talk about

    #import <Foundation/Foundation.h>
    
    @interface NSDictionary (changedKeys)
    - (NSArray*)changedKeysIn:(NSDictionary*)d;
    @end
    
    @implementation NSDictionary (changedKeys)
    - (NSArray*)changedKeysIn:(NSDictionary*)d {
        NSMutableArray *changedKs = [NSMutableArray array];
        for(id k in self) {
            if(![[self objectForKey:k] isEqual:[d objectForKey:k]])
                [changedKs addObject:k];
        }
        return changedKs;
    }
    @end
    
    int main(int argc, char *argv[]) {
        @autoreleasepool {
            NSDictionary *d1 = @{@"1":@"value",@"2":@"value",@"3":@"value",@"4":@"value"};
            NSDictionary *d2 = @{@"1":@"value",@"2":@"newvalue",@"3":@"value"};
    
            NSArray *ks = [d1 changedKeysIn:d2];
            NSLog(@"%@", ks);   
    
        }
    
        return 0;
    }
    

    Edit: self.allKeys changed to just self — a dictionary can be enumerated already

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

Sidebar

Related Questions

App.config: <add key=SaveDraftPath value=C:\Drafts\/> C#: var saveDraftPath = ConfigurationManager.AppSettings[SaveDraftPath]; var sfDialog = new SaveFileDialog();
App.config: <?xml version=1.0 encoding=utf-8 ?> <configuration> <appSettings> <add key=1 value=An error occured.\r\nPlease try again
app.get('/', function (req, res) { res.render('home.jade', { results: req.session.value }); }); What i would
App.config looks like this: <appender name=MemoryAppender type=log4net.Appender.MemoryAppender> <layout type=log4net.Layout.PatternLayout> <conversionPattern value=%date [%thread] %-5level -
My app is for expenses in every month, I have table with name Expense
My app is free and, using in-app purchases, I'd like to enable additional functionality.
App Engine Datastore cannot be queried for an aggregate result. Example: I have an
App Description: I have a UIWebview and a Toolbar beneath it. A button on
App runs on simulator on my MacBook Air, but not on iMac. I have
App Store We have been developing an app for quite some time now for

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.