I want to get value for variable guestname
from closure and guestname
is defined as global virable then pass this value to other class that use it. But the problem is that when i print out the guestname
outside the closure it's empty but inside i see the actual value. So when i passed guestname
to other class it pass nil caused problem. What is correct way to assign the value to guestname
and get this value out of closure? Thanks
queryUserID?.getFirstObjectInBackground(block: { (object, error) in
if error == nil {
guestname = object!.value(forKey: "username") as! String
}
})