Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between dispatch_queue_t! and dispatch_queue_t?

The headers say dispatch_get_global_queue returns global queue or NULL.

 * @result
 * Returns the requested global queue or NULL if the requested global queue
 * does not exist.
 */
@available(OSX 10.6, *)
@warn_unused_result
public func dispatch_get_global_queue(identifier: Int, _ flags: UInt) -> dispatch_queue_t!

Why is the return value dispatch_queue_t! instead of optional dispatch_queue_t?

like image 616
joels Avatar asked Feb 16 '26 12:02

joels


1 Answers

The dispatch_queue_t! is an optional, but it's an implicitly unwrapped one (saving you from having to manually unwrap it every time you use it).

When you see implicitly unwrapped optionals in Cocoa APIs, sometimes it just means that they haven't yet audited that particular API for nullability. Or perhaps they just wanted to save you from having to manually unwrap the optional yourself. Or perhaps it's an artifact that GCD objects employ a non-standard interface (it returns ARC-compatible objects but doesn't use the usual Objective-C * object references), so maybe the Swift bridging can't handle it gracefully.

like image 169
Rob Avatar answered Feb 18 '26 02:02

Rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!