在尝试实现我的代码时,我一直遇到很多问题。我是Swift的新手,语法令人沮丧。
我无法遍历字符串。我必须使用方法/库函数。
func findNextItem(from: String, in:[String]) -> String?{
return nil
}
//FUNCTION MUST WORK WITH THE BELOW CODE
let bucketList = ["Travel to Antarctica", "Climb Mount Everest", "Run a
marathon", "Write a book", "Build an iOS app"]
let item1 = findNextItem(from: "Write a book", in: bucketList)
let item2 = findNextItem(from: "Build an iOS app", in: bucketList)
let item3 = findNextItem(from: "Run a marathon", in: [])
print(item1!) // "Build an iOS app"
print(item2!) // "Travel to Antarctica"
print(item3) // nil