2010-10-19 59 views
16

以下日誌消息中的[]之間的內容是什麼?我在我的iPhone應用程序中得到了這個,我不知道該消息來自哪裏。我的第一個猜測將是一個行號,但它會在哪個文件?NSLog()輸出中方括號中的數字是什麼?

2010-10-19 08:56:12.006 Encore[376:6907] 

回答

26

第一個數字是進程ID,第二個是日誌線程的Mach端口。桌面示例:

2010-10-19 17:37:13.189 nc_init[28617:a0f] nc <CFNotificationCenter 0x10010d170 [0x7fff70d96f20]> - default <CFNotificationCenter 0x10010d2a0 [0x7fff70d96f20]> 

(gdb) i thread 
Thread 1 has current state "WAITING" 
    Mach port #0xa0f (gdb port #0x4203) 
    frame 0: main() at nc_init.m:10 
    pthread ID: 0x7fff70ebfc20 
    system-wide unique thread id: 0x167b49 
    dispatch queue name: "com.apple.main-thread" 
    dispatch queue flags: 0x0 
    total user time: 13232000 
    total system time: 16099000 
    scaled cpu usage percentage: 0 
    scheduling policy in effect: 0x1 
    run state: 0x3 (WAITING) 
    flags: 0x0 
    number of seconds that thread has slept: 0 
    current priority: 31 
    max priority: 63 
    suspend count: 0. 

(gdb) p/x (int)mach_thread_self() 
$1 = 0xa0f 

請注意0xa0f是如何報告爲線程的Mach端口的。

2

第一個數字是進程ID,不確定第二個,這一行將在每行打印到應用程序的控制檯之前。

可能是NSLog(@"");正在造成這種情況。

您的應用程序正在運行還是在此階段崩潰?

+0

我的應用程序在這一點上運行得很好。日誌消息的其餘部分正在抱怨一個沒有池的自動發佈的NSData實例,因此係統將其打印出來。我只是想弄清楚信息來自哪裏,但我現在就明白了。 – Robbie 2010-10-19 13:48:33

0

這實際上是一個進程ID。您可以在GDB控制檯中看到某行應爲「[切換到進程376]」的行。

1

第一個數字是進程ID,正如其他人所說的那樣。第二個數字是線程ID,至少我非常肯定這就是它...

相關問題