我将我的项目链接到AFNetwork,并具有以下示例代码:
var manager: AFHTTPRequestOperationManager = AFHTTPRequestOperationManager(baseURL: NSURL(string: "http://api.openweathermap.org"))
manager.GET("data/2.5/weather", parameters: nil, success:{(operation: AFHTTPRequestOperation!, obj: AnyObject!) in
println("success!")
},
failure:{(operation: AFHTTPRequestOperation!, error: NSError!) in
println("fail!")
}
)
如果我成功设置了断点,则当我这样做时,obj和operation都是“nil”:
po operation
po obj
但在变量下,操作说:
operation Swift.ImplicitlyUnwrappedOptional<__ObjC.AFHTTPRequestOperation> 0x7b029e30 0x7b029e30
obj说:
obj Swift.ImplicitlyUnwrappedOptional<AnyObject> (instance_type = Builtin.RawPointer = 0x7b02c3b0 -> 0x00ea2940 (void *)0x00ea2954: OBJC_METACLASS_$___NSCFDictionary) Some
知道如何打印出这些值吗?谢谢!
最佳答案
这对我来说是成功的结束println("operation: \(operation)")
关于ios - 为什么变量在此AFNetworking块中全部显示为nil( swift )?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25007723/