我想知道在iPhone OS 3.0或更高版本中直接使用蓝牙而不使用GameKit的可能性.有人可以提供任何例子吗?

你如何检索线程的"名称"?
(看到应用暂停的xcode图片,在哪里,我所谓的"名称"以黄色突出显示,"com.apple.coremedia.player.async"...我可以检索正在运行的线程,并尝试了以下内容,没有运气
mach_msg_type_number_t count, i;
thread_act_array_t list;
task_threads(mach_task_self(), &list, &count);
for (i = 0; i < count; i++) {
if (list[i] == mach_thread_self()) continue;
char theName[16];
memset(theName, 0x00, sizeof(theName));
pthread_getname_np(list[i], theName);
printf("The thread name is %s.\n", theName);
}
Run Code Online (Sandbox Code Playgroud)
注意:我不是要求当前线程的线程名称..我有兴趣从运行线程集中获取线程名称(参见上面的示例)..所以关于[NSThread currentThread]的解决方案将不起作用
我有一个全局字典变量,它将在被多次调用的函数中使用。我无法控制何时调用函数,也无法控制我正在编写的函数之外的范围。仅当变量未初始化时,我才需要对其进行初始化。初始化后,我将向其添加值。
global dict
if dict is None:
dict = {}
dict[lldb.thread.GetThreadID()] = dict[lldb.thread.GetThreadID()] + 1
Run Code Online (Sandbox Code Playgroud)
不幸的是,我得到
NameError: global name 'dict' is not defined
Run Code Online (Sandbox Code Playgroud)
我知道我应该定义变量,但是由于这段代码被多次调用,dict = {}所以我只是说每次调用代码时我都会重新定义变量,除非我能以某种方式检查它是否未定义,并且只定义它然后。
iphone ×2
bluetooth ×1
bonjour ×1
c ×1
dictionary ×1
global ×1
ios ×1
objective-c ×1
python ×1