self
is a reserved word in Swift. Since you're creating a new local var called self you need to mark it with back-ticks, as explained in the link from rmaddy.
Note that the usual convention for mapping weak self to a strong var is to use the name strongSelf
:
() -> Void = { [weak self] in
guard let strongSelf = self else {
//your code to call self.callMethod2() can't succeed inside the guard (since in that case weak self is nil)
//self.callMethod2()
return //You must have a statement like return, break, fatalEror, or continue that breaks the flow of control if the guard statement fails
}
strongSelf.callMethod3()
}