python - 用 Pyobjus 包装 Objective C
问题描述
我想使用 Pyobjus 在 Python 中包装以下目标 C,但我没有使用目标 C 的经验。我该怎么做呢?
// create the client with a unique client ID
NSString *clientID = ...
MQTTClient *client = [[MQTTClient alloc] initWithClientId:clientID];
// connect to the MQTT server
[self.client connectToHost:@"iot.eclipse.org"
completionHandler:^(NSUInteger code) {
if (code == ConnectionAccepted) {
// when the client is connected, send a MQTT message
[self.client publishString:@"Hello, MQTT"
toTopic:@"/MQTTKit/example"
withQos:AtMostOnce
retain:NO
completionHandler:^(int mid) {
NSLog(@"message has been delivered");
}];
}
}];
来自这里的代码
我查看了Pyobjus docsautoclass
,但是在将函数与类一起使用时出现错误MQTTClient
:
MQTTClient = autoclass("MQTTClient")
给出错误Unable to find class b'MQTTClient'
。
解决方案
推荐阅读
- c++ - 如果堆上不存在以下语句,那么它放在内存中的什么位置?
- r - 使用 r 中的 barplot 在条形图顶部标注注释
- laravel-8 - Laravel 8:未定义的方法'createToken' intelephense(1013)
- jail-shell - 越狱:作曲家:找不到命令
- python - 用于实现分支定界技术以解决非凸非线性整数多目标优化问题的 Python 包?
- python - 如何区分不同服务器的 discord.py 余额?
- javascript - 如何按属性对数组对象进行分组?
- python - 用 30 秒的断点和颜色绘制时间序列数据
- r - 将变量分配给绘图标题中的 R 表达式
- java - SimpleDateFormat 中月份的奇怪问题