【问题标题】:Why does the debugger 'po' works with 'var' vs 'let'?为什么调试器 'po' 与 'var' vs 'let' 一起工作?
【发布时间】:2014-10-07 20:33:43
【问题描述】:

为什么调试器 'po' 与 var 一起工作:

var myDict = currentImageDownloader.dict

如下图:

(lldb) po myDict
Some
 {
  [0] = {
    key = "ispublic"
    value = (instance_type = Builtin.RawPointer = 0xb000000000000013)


    (lldb) po myDict
    error: <EXPR>:1:1: error: use of unresolved identifier 'myDict'
    myDict
    ...

但是通过“让”:

let myDict = currentImageDownloader.dict

调试器“po”不起作用:

(lldb) po myDict
error: <EXPR>:1:1: error: use of unresolved identifier 'myDict'
myDict

^


虽然我可以使用调试器的 frame 命令通过 'let' 或 'var' 查看所有内容:
(lldb) fr v 
(UICollectionView) collectionView = 0x00007fc2d2821600 {
  UIKit.UIScrollView = {
    UIKit.UIView = {
      UIKit.UIResponder = {
        ObjectiveC.NSObject = {}
      }
    }
  }
}
(NSIndexPath) indexPath = 0xc000000000000016 {
  ObjectiveC.NSObject = {}
}
(FlickrSwift.ViewController) self = 0x00007fc2d2580f20 {
  UIKit.UIViewController = {
    UIKit.UIResponder = {
      ObjectiveC.NSObject = {}
    }
  }
  collectionView = Some
}
(FlickrSwift.ImageDownloader) currentImageDownloader = 0x00007fc2d4449750 {
  image = nil
  bigImage = nil
  dict = Some {
    [0] = {
      key = "ispublic"
      value = (instance_type = Builtin.RawPointer = 0xb000000000000013)
    }
    [1] = {
      key = "height_sq"
      value = (instance_type = Builtin.RawPointer = 0xb0000000000004b3)
    }
    [2] = {
      key = "url_m"
      value = (instance_type = Builtin.RawPointer = 0x00007fc2d25131a0 -> 0x00000001088e7488 (void *)0x00000001088e7438: __NSCFString)
    }
    [3] = {
      key = "title"
      value = (instance_type = Builtin.RawPointer = 0x00007fc2d25a7030 -> 0x00000001088e7488 (void *)0x00000001088e7438: __NSCFString)
    }
    [4] = {
      key = "isfamily"
      value = (instance_type = Builtin.RawPointer = 0xb000000000000003)
    }
    ...
  }
  descString = nil
}
(AnyObject) cell = <variable not available>

(UIImageView) photoImageView = <variable not available>

(UIImage) image = <variable not available>

【问题讨论】:

标签: swift lldb


【解决方案1】:

“let”变量的调试信息中存在一些错误,导致 lldb 无法正确理解它们。这些都应该在即将发布的 Xcode 版本中得到修复。获得新版本后,您需要重新编译代码,但之后您应该能够看到它们。

如果您不是,请向http://bugreporter.apple.com 提交错误。

【讨论】:

    猜你喜欢
    • 2020-06-12
    • 2019-05-31
    • 2016-08-19
    • 2010-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-15
    • 1970-01-01
    相关资源
    最近更新 更多