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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -