I have a function in swift to return a string from array, if the array has value return directly, if not I need load it from server and return the value from callback, I don't know how to do it, something like
func getValue(idx: Int)->string {
if arrayValue.count <= 0 {
callbackfunc() { arrayValue in
return arrayValue[idx]
}
} else {
return arrayValue[idx]
}
}
but it is impossible to return from callback, any help? thank you very much