【发布时间】:2020-11-04 08:38:39
【问题描述】:
我是 Objective C 和 C++ 的新手,我已经在 this tutorial 之后在 Objective C 中成功调用了一个 C++ 函数。
但是,上面教程中的示例函数没有输入参数,它是这样的:
//In example C++ file:
std::string Greeting::greet() {
return someString;
}
//In example Objective-C file:
NSString* newTitle = [NSString stringWithCString:greeting.greet().c_str() encoding:[NSString defaultCStringEncoding]];
就我而言,我有一个 C++ 函数,例如:
std::string Greeting::newGreet(std::vector<std::string> s) {
// do something
// f(s)
return someString;
}
Objective-C 中没有 std::vector<:string>,所以我需要将 NSArray
如何进行这种转换,并将其传递给newGreet() 函数?
【问题讨论】:
-
Objective-C++中有std::vector<std::string>
标签: c++ objective-c nsstring nsarray