更新时间:2022-02-07 06:21:16
p>我已经测试发现, AnyObject
是碰巧的事件。你不需要 AnyObject
作为swift将推断类型从数组地址
I have tested and found that AnyObject
is casuse of crash.You do not need AnyObject
as swift will infer type from array addresses
var host = "192.168.103.13"
if host != "\0" {
let hostRef = CFHostCreateWithName(kCFAllocatorDefault, host.bridgeToObjectiveC()).takeRetainedValue()
var resolved = CFHostStartInfoResolution(hostRef, CFHostInfoType.Addresses, nil)
let addresses = CFHostGetAddressing(hostRef, &resolved).takeRetainedValue() as NSArray
println(addresses)
//Remove `AnyObject` as there is no need.Swift will infrence from array addresses
for address in addresses {
println(address) // address is of type NSData.
}
}