IOS 将 boost 类声明为类变量

标签 ios objective-c boost

我正在尝试使用 boost 库类进行一些套接字通信。我需要将此变量声明为类实例,因此我声明如下,

@interface Custom_View : UIView{
    boost::asio::io_service io_service_2;
    tcp::resolver r_2(io_service_2);
    client c_2(io_service_2);
    boost::thread* dvr_thread_2;
}

越来越像

Custom_View.h:46:23: Unknown type name 'io_service_2'; did you mean 'boost::asio::io_service'?
Custom_View.h:47:16: Unknown type name 'io_service_2'; did you mean 'boost::asio::io_service'?
Custom_View.h:46:19: Field 'r_2' declared as a function
Custom_View.h:47:12: Field 'c_2' declared as a function

我该如何解决这个错误。

最佳答案

如果您尝试声明一个 Objective-C 类或静态变量,则必须在 @interface 声明中的花括号之外进行。例如(如果您没有声明任何实例变量,可以省略“{}”):

@interface SubclassName : SuperclassName

Type variableName;

也就是说,我不熟悉 boost 库,而且您代码中声明的变量似乎不是有效的 Objective-C。快速 Google 搜索显示了这个 GitHub 项目,它可能会帮助您找到正确的方向:https://github.com/mz2/boostoniphone

关于IOS 将 boost 类声明为类变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38748949/

相关文章:

ios - 如何将圆角半径设置为 UIBezierPath

objective-c - 如何设置章节标题以使用 UITableView 样式分组?

c++ - 在 cmd pmt 中执行带空格的文件名 从 C++ 程序传递

c++ - 获取指向类型的boost shared_ptr

ios - iOS phone gap 发送邮件的问题

ios - Appstore发布应用的神奇记录,核心数据迁移

javascript - 使用 "stringByEvaluatingJavaScriptFromString"单击 UIWebView 中的链接

iphone - 如何减少 iPhone 应用程序的代码大小?

c++ - boost type_traits is_array

ios - 我需要使用 4 英寸设备测试 3.5 英寸的 iOS 应用程序