I have a web service which returns response in json.
I created a separate class for data access in xcode(swift) for iphone.
What I want to do is call a function in the data access layer, which returns the response dictionary, WHEN FETCHING IS COMPLETE.
Problem: How return ONLY WHEN fetching from service is complete.
Ex: Student Table->Click a student->Fetch data of student->Return data when fetching completes
func getUser(userID:String)->NSDictionary{
        let manager = AFHTTPRequestOperationManager()
        let parameters = ["uid":userID]
        manager.POST(urlStudentInfo, parameters: parameters,
            success: {(operation: AFHTTPRequestOperation!,responseObject: AnyObject!) in
                print("JSON success: " + responseObject.description)
                if let responseDic = responseObject as? NSDictionary{
                    let isUser = responseDic["status"] as! Bool
                    
                    if isUser{
                        
                        
                        
                    }else{
                        
                    }
                }
                
            },
            
            failure: { (operation: AFHTTPRequestOperation!,error: NSError!) in
                
        })
    return response
}
This is my function structure. Problem is fetching happens after the return is done. So the return is always nil.
Anyone have a suggestion to return only after fetching is complete?
 
     
     
     
    