我的目标是将UsersArray的内容移动到generateUserData()中,以便我可以在TableViewController中显示它。
[usernameList()和idList()从URL请求中获取响应消息]
final class UsersData {
static func generateUsersData() -> Array<User>
{
return [
User(id: "111", username: "Bill@comcast.net"),
User(id: "222", username: "Oscar Peterson@yahoo.com"),
User(id: "333", username: "DaveBrubeck@gmail.com")
]
}
}
func makeUsers() {
usernameList() {
inputArray in
arrayOfUsernames = inputArray as! [String]
idList() {
inputArray in
arrayOfids = inputArray as! [String]
var counter = arrayOfids.count - 1
print(counter)
while counter > 0 {
usersArray.append(User(id: arrayOfids[counter], username: arrayOfUsernames[counter]))
counter -= 1
}
print("makeUsers() creates this array in idList() closure: \(usersArray)")
}
}
}
打印到控制台:
makeUsers() creates this array in idList() closure: [Project1.User(id: Optional(""), username: Optional("")), Project1.User(id: Optional("62"), username: Optional("83068151@qq.com")), Project1.User(id: Optional("56"), username: Optional("830681511@qq.com")), Project1.User(id: Optional("55"), username: Optional("in@ultrices.edu")), Project1.User(id: Optional("54"), username: Optional("non.lacinia@pretiumet.com")), Project1.User(id: Optional("53"), username: Optional("pede@utodio.org")), Project1.User(id: Optional("52"), username: Optional("tincidunt@congueInscelerisque.co.uk")), Project1.User(id: Optional("51"), username: Optional("enim@liberoProin.ca")), Project1.User(id: Optional("50"), username: Optional("amet.massa@nectellus.net")), Project1.User(id: Optional("49"), username: Optional("auctor.Mauris@nibhenimgravida.edu")), Project1.User(id: Optional("48"), username: Optional("Curae.Phasellus.ornare@parturientmontes.ca")), Project1.User(id: Optional("47"), username: Optional("pede.blandit@Pellentesquehabitant.net")), Project1.User(id: Optional("46"), username: Optional("Maecenas@natoquepenatibus.ca")), Project1.User(id: Optional("45"), username: Optional("non.lobortis@nunc.edu")), Project1.User(id: Optional("44"), username: Optional("Sed@interdum.net")), Project1.User(id: Optional("43"), username: Optional("vehicula.risus@urnasuscipit.com")), Project1.User(id: Optional("42"), username: Optional("libero@dui.co.uk")), Project1.User(id: Optional("41"), username: Optional("fames@Nullatemporaugue.edu")), Project1.User(id: Optional("40"), username: Optional("eget.ipsum.Suspendisse@facilisis.ca")), Project1.User(id: Optional("39"), username: Optional("felis.Nulla.tempor@adipiscinglacusUt.net")), Project1.User(id: Optional("38"), username: Optional("erat.neque.non@in.co.uk")), Project1.User(id: Optional("37"), username: Optional("tincidunt.dui.augue@sedturpis.ca")), Project1.User(id: Optional("36"), username: Optional("ultrices.iaculis@adipiscingelitAliquam.org")), Project1.User(id: Optional("35"), username: Optional("montes.nascetur@etmagnisdis.edu")), Project1.User(id: Optional("34"), username: Optional("Phasellus.nulla.Integer@nunc.edu")), Project1.User(id: Optional("33"), username: Optional("Donec.tincidunt@Quisque.edu")), Project1.User(id: Optional("32"), username: Optional("In@afelisullamcorper.edu")), Project1.User(id: Optional("31"), username: Optional("neque.Nullam.ut@eleifend.edu")), Project1.User(id: Optional("30"), username: Optional("mus.Aenean@tellussemmollis.org")), Project1.User(id: Optional("29"), username: Optional("Donec.dignissim@Nunc.org")), Project1.User(id: Optional("28"), username: Optional("gravida.molestie@habitant.edu")), Project1.User(id: Optional("27"), username: Optional("egestas@sedtortor.org")), Project1.User(id: Optional("26"), username: Optional("non.enim@semut.com")), Project1.User(id: Optional("25"), username: Optional("nec@tinciduntvehicula.ca")), Project1.User(id: Optional("24"), username: Optional("nec.ante.blandit@consequatdolor.ca")), Project1.User(id: Optional("23"), username: Optional("sit.amet.metus@Pellentesquetincidunttempus.org")), Project1.User(id: Optional("22"), username: Optional("convallis.dolor.Quisque@natoquepenatibuset.edu")), Project1.User(id: Optional("21"), username: Optional("lacus@molestietellus.com")), Project1.User(id: Optional("20"), username: Optional("dui@NullaaliquetProin.edu")), Project1.User(id: Optional("19"), username: Optional("ullamcorper.velit@necmalesuadaut.com")), Project1.User(id: Optional("18"), username: Optional("risus@nibh.ca")), Project1.User(id: Optional("17"), username: Optional("scelerisque.lorem@dolorsit.net")), Project1.User(id: Optional("16"), username: Optional("Nulla.interdum@parturientmontesnascetur.net")), Project1.User(id: Optional("15"), username: Optional("ipsum.non@erat.co.uk")), Project1.User(id: Optional("14"), username: Optional("commodo.tincidunt@molestiesodales.com")), Project1.User(id: Optional("13"), username: Optional("cursus.Integer.mollis@eleifendnon.net")), Project1.User(id: Optional("12"), username: Optional("eleifend.vitae@etmagnisdis.co.uk")), Project1.User(id: Optional("11"), username: Optional("et.lacinia.vitae@inconsequatenim.net")), Project1.User(id: Optional("10"), username: Optional("dictum.magna@auctorullamcorpernisl.com")), Project1.User(id: Optional("9"), username: Optional("tempus.mauris.erat@ametfaucibus.net")), Project1.User(id: Optional("8"), username: Optional("iaculis.odio.Nam@ligulatortor.org")), Project1.User(id: Optional("7"), username: Optional("enim.condimentum@elementum.org")), Project1.User(id: Optional("6"), username: Optional("parturient@Aeneanmassa.com")), Project1.User(id: Optional("5"), username: Optional("")), Project1.User(id: Optional("4"), username: Optional("testguy@aol.com"))]