我写的应用程序获取列表的姓氏和姓氏我在使用RestKit和MLPAutoCompleteTextField时写下姓氏并不显示自动填充文本
var listDoctors = [String]()
func autoCompleteTextField(textField: MLPAutoCompleteTextField!, possibleCompletionsForString string: String!, completionHandler handler: ([AnyObject]!) -> ()) {
let appDelegate: AppDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate)
var requestParameters: [NSObject:AnyObject] = [NSObject: AnyObject]()
requestParameters["name"] = textField.text
appDelegate.objectManager.getObjectsAtPath("/doctors", parameters: requestParameters, success: {
(rkoperation: RKObjectRequestOperation!, rkmap: RKMappingResult!) -> Void in
if let doctors = rkmap.array() as? [Doctor] {
for doctor: Doctor in doctors {
let nameDoctors = doctor.firstname
let lastnameDoctors = doctor.lastname
let list = nameDoctors + lastnameDoctors
self.listDoctors.append(list)
}
}
handler(self.listDoctors)
}, failure: {
(rkoperation: RKObjectRequestOperation!, error: NSError!) -> Void in
print("Load filed with error: @", error!)
self.performSelectorOnMainThread(#selector(AppDelegate.showFetchError), withObject: nil, waitUntilDone: true)
})
}
}