ios - Unable to access variable within a function in Swift -


in function i'm building socket method can't access pcount after socket method in function

code

use of unresolved identifier 'pcount' why?

pscount async function can't return in it. in case, socket.on have't finished pscount still return should code:

func pscount(handlefinish:((pcount:int)->())){     socket.on("reply") { data, act in         let json = json(data)         let pcount:int = json[0].count         handlefinish(pcount: pcount:int)     } } 

and call it:

self.pscount { (pcount) -> () in         print(pcount)     } 

Comments