ho un enum di metodi HTTP:Come impostare la condizione dei breakpoint condizionali in Swift con self ed enum?
enum HTTPMethod: String {
case GET = "GET"
case POST = "POST"
}
e ho una classe di richiesta e di una classe richiesta di avvolgitore:
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
}
}
Ho impostato un punto di interruzione condizionale sulla linea:
return request.method.rawValue == incomingRequest.HTTPMethod
con condizione:
self.request.method == HTTPMethod.POST
e quindi la fermata debugger alla linea, con un messaggio di errore:
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
E se elimino self
e cambiare la condizione:
request.method == HTTPMethod.POST
messaggio di errore è come le seguenti linee:
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
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C'è un modo per risolvere questa domanda?
Aggiornamento:
E 'in grado di controllare il valore di self.request.method
utilizzando il comando LLDB:
fr v self.request.method
E se uso una costante locale per memorizzare il valore, il debugger può essere fermato al giusta posizione:
// Use a local constant to store the HTTP method
let method = request.method
// Condition of breakpoint
method == HTTPMethod.POST
Aggiornamento 2:
Sto usando Xcode 6.3.1