C++ / Objective-C++ - How can I store a C++ variable in an NSDictionary? -


i have c++ variable of type std::vector<std::bitset<128> > defined , populated in c++ class (which called objective-c++ class.)

i store object in nsdictionary - or equivalent of. can't add std::vector<std::bitset<128> > nsdictionary because it's not of type id.

so question this: how can achieve same concept? how can store std::vector<std::bitset<128> > in dictionary of sorts? can wrap vector object in id type somehow? if it's not direct dictionary, there method use? need mutable, can add key/object's @ runtime.

i'v seen std::map<std::string, std::string>, i'm not sure if it's i'm looking for. nor have found examples on being mutable.

does have idea how achieve this?

actually nsvalue seems solution. @taum's advice correct cases (when store objects somewhere , sure pointers working). in case you've created object , it's lifetime limited, need push object further, use nsvalue method

std::vector<std::bitset<128>> cppvector; nsvalue *value=[nsvalue valuewithbytes:&cppvector objctype:@encode(std::vector<std::bitset<128>>)]; 

when need value back:

std::vector<std::bitset<128>> cppvector; [value getvalue:&cppvector]; 

that works simple structs too.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -