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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:04:50+00:00 2026-06-15T23:04:50+00:00

I want to convert values of std::map to NSMutableArray element. My CPP code is

  • 0

I want to convert values of std::map to NSMutableArray element.
My CPP code is passing std::map (with one int and std::string) to an Objective-C function using interface function.

But i am not able to convert this std::map to NSMutableArray.

CPP Code:
------------------------------------------------------------------    
typedef std::map<int, std::string> TemList;
temList temList;
temList[10]="an element";
temList[23]="another element";
temList[545]="last";

passing this map to an objective-c code using interface function. 

Objective-c Code
------------------------------------------------------------------  
- (void) testListUpdate:(const TemList&) pList
{
    NSMutableArray *mArray = [NSMutableArray alloc]init];
    

    for (TemList::const_iterator ii = pList.begin(); ii != pList.end(); ++ii)
    {
        ListItem item = [[ListItem alloc] init]
        
        // PROBLEM **** I am Not able to convert this ******
        item.name = ii->second.c_str();
        item.mId = (int) ii->first;
    
        [mArray addObject:item];
    
        //printf("OBJC Value[%s]: Key[%d]\n", ii->second.c_str(), ii->first);
    }
}

// Interface function implementation 
void interfaceListUpdate(void *self, const TemList& pList)
{
    printf("ObjectiveC Interface Function size[%d]\n", pList.size());
    [(id) self testListUpdate:pList];
}

// Using this struct as Array item
@interface ListItem : NSObject
{
    NSString *name;
    int mId;
}

@end

Also i want to use mArray for displaying table view rows.
How should i do it.

  • 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-15T23:04:52+00:00Added an answer on June 15, 2026 at 11:04 pm

    Just use

    NSString *string = [NSString stringWithCString:cppString.c_str() 
                                          encoding:NSUTF8StringEncoding];
    

    or whatever NSStringEncoding works for your particular content!

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

Sidebar

Related Questions

I have some double values I want to convert to a string with this
I want to convert the string to character array. Further, the values in character
I have a string 1.0.0.1; I want to convert this string to numeric values
I want to convert to std::string to System::String^ in Visual C++ environment. I know
Can someone please post a simple code that would convert, System::String^ To, C++ std::string
I have the following function void AddNodeValue(XMLNode& node, std::string& value); I want to use
I want to convert an integer value to a string of hex values, in
In a SELECT statement I want to convert values to strings ie. SELECT TO_STRING(value).
I want to convert characters into integers based on predetermined values, for example: a
I want to convert a pointer *int to its real value int , in

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.