Ios 如何使用self和enum在Swift中设置条件断点的条件?

Ios 如何使用self和enum在Swift中设置条件断点的条件?,ios,swift,debugging,enums,lldb,Ios,Swift,Debugging,Enums,Lldb,我有一个HTTP方法的枚举: enum HTTPMethod: String { case GET = "GET" case POST = "POST" } 我有一个请求类和一个请求包装器类: class Request { let method: HTTPMethod = .GET } class RequestWrapper { let request: Request func compareToRequest(incomingRequest: NSURLRequ

我有一个HTTP方法的枚举:

enum HTTPMethod: String {
  case GET = "GET"
  case POST = "POST"
}
我有一个请求类和一个请求包装器类:

class Request {
  let method: HTTPMethod = .GET
}

class RequestWrapper {
  let request: Request

  func compareToRequest(incomingRequest: NSURLRequest) -> Bool {

     // Next line is where the conditional breakpoint set.
     return request.method.rawValue == incomingRequest.HTTPMethod
  }
}
我在行上设置了一个条件断点:

return request.method.rawValue == incomingRequest.HTTPMethod
有条件:

self.request.method == HTTPMethod.POST
然后调试器在该行停止,并显示一条错误消息:

Stopped due to an error evaluating condition of breakpoint 1.1:     
"self.request.method == HTTPMethod.POST"
Couldn't parse conditional expression:
<EXPR>:1:1: error: use of unresolved identifier 'self'
self.request.HTTPMethod == HTTPMethod.POST
错误消息如下所示:

Stopped due to an error evaluating condition of breakpoint 1.1:  
"request.method == HTTPMethod.POST"
Couldn't parse conditional expression:
<EXPR>:1:1: error: could not find member 'method'
request.method == HTTPMethod.POST
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
如果我使用一个局部常量来存储该值,调试器可以在正确的位置停止:

// Use a local constant to store the HTTP method
let method = request.method

// Condition of breakpoint
method == HTTPMethod.POST
更新2:


我使用的是Xcode 6.3.1,这显然是一个lldb错误。您没有提到您正在使用的工具的版本。如果您没有使用6.3.1或更高版本,请再次尝试使用该版本。如果您仍然看到问题,请向提交错误

注意,
frame-var
expr
是完全不同的<代码>帧变量仅直接使用DWARF调试信息打印局部变量的值,而不是表达式计算器。例如,它不知道如何做
==
。我想如果你做到了:

(lldb) self.request.method == HTTPMethod.POST
当在该断点处停止时,您将看到相同的效果

表达式解析器必须扮演一个额外的把戏,冒充类的方法(通过self获得透明引用,等等)并且,要做到这一点有点棘手。很明显,在你的情况下,我们没有正确地完成工作

// Use a local constant to store the HTTP method
let method = request.method

// Condition of breakpoint
method == HTTPMethod.POST
(lldb) self.request.method == HTTPMethod.POST