Posts

Post marked as solved
17 Replies
7.3k Views
Does CFNetwork provide API to open a socket on a particular interface? This post suggestsusing SCNetworkInterfaceCopyAll and SCNetworkInterfaceGetInterfaceType to find an interface with a desired type. But I get an error saying SCNetworkInterfaceCopyAll is unavailable in Xcode 8.3.2.If SCNetworkInterfaceCopyAll is unavailable, how would you search the result of getifaddrs to find an interface with a type (e.g. kSCNetworkInterfaceTypeIEEE80211 (wifi) vs kSCNetworkInterfaceTypeWWAN (cell)).Thanks!
Posted
by mjc.
Last updated
.
Post marked as solved
3 Replies
1.6k Views
When URLSession.dataTask(with request: URLRequest, completionHandler:) returns a nil error, is the URLResponse response parameter guaranteed to be an HTTPURLResponse, so that it is safe to force downcast the URLResponse to an HTTPURLResponse?This article does not force cast the URLResponse to an HTTPURLResponse when there is no error:https://developer.apple.com/documentation/foundation/url_loading_system/fetching_website_data_into_memoryThese examples do:https://developer.apple.com/documentation/network/debugging_http_server-side_errorshttps://forums.developer.apple.com/message/351326#351326Thanks!
Posted
by mjc.
Last updated
.
Post not yet marked as solved
1 Replies
2.6k Views
The Xcode 10 release notes mention a static analyzer feature that checks for a common performance anti-pattern when using Grand Central Dispatch, involving waiting on a callback using a semaphore.1. For a function that needs to synchronously return a value from an asynchronous API, is there a more efficient solution than using a DispatchWorkItem as shown here?https://forums.developer.apple.com/message/251273#251577 2. The analyzer produces the following warning for the anti-pattern: "Waiting on a callback using a semaphore creates useless threads and is subject to priority inversion; consider using a synchronous API or changing the caller to be asynchronous"What is the priority inversion the warning refers to?At the time of this writing, the analyzer doesn’t produce a warning for the anti-pattern in Swift as it does in Objective-C.Thanks!
Posted
by mjc.
Last updated
.