gpt4 book ai didi

ios - 创建列表对象 Swift

转载 作者:行者123 更新时间:2023-11-29 00:56:25 25 4
gpt4 key购买 nike

:我有问题。我创建列表医生显示名字和姓氏。如何反对listdoctor

 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
// Wykonanie żądania
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 {
// show error Experession resolves to an unused I-value
doctor.firstname
self.listDoctors.append(doctor.firstname)
}
}
}, failure: {
(rkoperation: RKObjectRequestOperation!, error: NSError!) -> Void in
print("Load filed with error: @", error!)
self.performSelectorOnMainThread(#selector(AppDelegate.showFetchError), withObject: nil, waitUntilDone: true)
})
handler(listDoctors)

最佳答案

   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
// Wykonanie żądania
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 {
var nameDoctoers = doctor.firstname

self.listDoctors.append(nameDoctors)
}
}
}, failure: {
(rkoperation: RKObjectRequestOperation!, error: NSError!) -> Void in
print("Load filed with error: @", error!)
self.performSelectorOnMainThread(#selector(AppDelegate.showFetchError), withObject: nil, waitUntilDone: true)
})
handler(listDoctors)
}
}

关于ios - 创建列表对象 Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37589459/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com