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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:20:07+00:00 2026-06-08T00:20:07+00:00

so I have a couple NSMutableDictionarys and each key/valeu pair for a specific dictionary

  • 0

so I have a couple NSMutableDictionarys and each key/valeu pair for a specific dictionary hold either a string or integer value. I would like to know if there is a way to iterate through the dictionary and concatenate the values. In PHP I could do something like this using an array

// either the dictionary holds all integers or all string values
$integer_array = array( 'a' => 2, 'b' => 9, 'c' => 2, 'd' => 0, 'e' => 1 );

foreach( $integer_array as $key => $value ) {
    $concatenated_value .= $value;
}

// cast to int
$concatenated_value = ( int ) $concatenated_value;

// prints: 29201
echo $concatenated_value;

I could also use the implode() as well

$concatenated_value = ( int )(implode("", $integer_array));

// prints: 29201
echo $concatenated_value;

is there something like this for iOS Objective-C?

  • 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-08T00:20:09+00:00Added an answer on June 8, 2026 at 12:20 am

    I don’t believe there is a predefined function for it. To me, this doesn’t seem like a very common thing to do (is it common in PHP?). I suppose the code would look like this in theory:

    int finalVal = 0;
    for (NSString *key in keyArray)
    {
        //If it is variable between NSString and NSNumber as you say, you will
        //need to do type checking here.
        NSNumber *numVal = [dictionary objectForKey:key];
        int num = [numVal intValue];
    
        //----Don't need this part if all values are single digits
        while(num > 10)
        {
            finalVal += num;
            finalVal *= 10;
            num /= 10;
        }
        //--------------------------------------------------------
    
        finalVal += num;
        finalVal *= 10;
    }
    finalVal /= 10;
    

    However, this is very unlikely to produce the results you want since dictionaries are not ordered. I think you need a different data structure or an array holding the keys in the order you inserted them (but at that point you might as well just use an array).

    EDIT Since you are using an ordered array of keys, I edited the answer above.

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

Sidebar

Related Questions

I have couple of statements, the pseudo code would look something like this: insert
I have couple of ideas in my brain which I would like to bring
I have couple areas with labels. When I hover an area I would like
I have couple of servlets designed to hold its own message source, but there
I have couple of rows in database table (lets call it Customer), each row
I have couple of controls in the page. I need to modify these value
I have couple of hyperlinks on my website. What I want is to remove
I have couple of dozen pieces of data that I need to save and
I have couple of formulas and data coming from database. I want to refresh
I have couple questions regarding some C++ rules. Why am I able to call

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.