You do not pass [weak self] ()
as an argument to a closure.
[weak self]
is a capture list and precedes the
- parameter list/return type declaration
() -> Void
in the closure expression.
The return type or both parameter list and return type can be omitted if they can
be inferred from the context, so all these are valid
and fully equivalent:
dispatch_async(dispatch_get_main_queue()) { [weak self] () -> Void in
self?.doSomething()
}
dispatch_async(dispatch_get_main_queue()) { [weak self] () in
self?.doSomething()
}
dispatch_async(dispatch_get_main_queue()) { [weak self] in
self?.doSomething()
}
The closure takes an empty parameter list ()
and has a Void
return type.