std::mapの値をNSMutableArray要素に変換したいと思います。
私のCPPコードは、インターフェイス関数を使用してstd :: map(1つのintとstd :: stringを含む)をObjective-C関数に渡しています。
しかし、このstd::mapを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
mArray
また、テーブルビューの行を表示するために使用したいと思います。
どうすればいいですか。