0

我正在使用 lldb 在 Mountain Lion 10.8.2 中使用 Xcode 4.5.1 调试 iOS 应用程序。

有时我会尝试在断点处检查调试器窗口中的 iVar:

po _currentSale

并会收到回复:

self->_currentSale 的打印描述:(Sale *) _currentSale = 0x081cd7e0

其他时候我会收到这个回复(这是我想要的):

self->_currentSale 的打印描述: '<'Sale: 0x81cd7e0'>' (entity: Sale; id: 0x81dd670 ; data: { car​​dNumber = "\U2022\U2022\U2022\U2022\U2022\U2022\U2022\U2022\U2022 \U2022\U2022\U20220001"; cvv = 222; emailAddress = "k@w.com"; expirationDate = 0413; lastStatus = 已批准; purchaseNumber = 00000008; saleAmount = 230; saleDate = "2012-10-20 08:06: 45 +0000";sectionIdentifier = 20121020;tipPercentage = 15;交易 = ("0x75df620'<'x-coredata://4A0DEB78-C770-4CE2-8A5D-878F51294D6D/Transaction/p11'>'");邮编 = 33333; })

为什么有时给我对象地址和其他人的完整描述之间的回复会有所不同?我的 Sale 对象是一个 Core Data 对象(如果有什么不同的话)。

4

1 回答 1

0

我不肯定,但我认为这不是来自 lldb。 po是对调用的薄薄的一层char *_NSPrintForDebugger(id),您可以通过_NSPrintForDebugger直接调用自己来轻松测试文本的来源,v。

Process 10842 stopped
* thread #1: tid = 0x1f03, 0x00000001000018f9 a.out`main + 153 at objc-prog.m:88, stop reason = step over
    #0: 0x00000001000018f9 a.out`main(argc=1, argv=0x00007fff5fbffb18) + 153 at objc-prog.m:88
   85   
   86       NSString *a = @"hi there";
   87   
-> 88       [object randomFunc];

(lldb) p a
(NSString *) $1 = 0x0000000100002470 @"hi there"   // lldb's built-in NSString summary formatter

(lldb) po a
(NSString *) $2 = 0x0000000100002470 hi there

(lldb) p (char*)_NSPrintForDebugger(a)
(char *) $4 = 0x000000010010f400 "hi there"

(lldb) p (char*)_NSPrintForDebugger(0x0000000100002470)
(char *) $3 = 0x0000000100114c60 "hi there"
于 2012-10-21T21:39:58.423 回答