Using Predicate in Swift

后端 未结 8 900
陌清茗
陌清茗 2020-12-07 12:16

I\'m working through the tutorial here (learning Swift) for my first app: http://www.appcoda.com/search-bar-tutorial-ios7/

I\'m stuck on this part (Objective-C code)

8条回答
  •  一整个雨季
    2020-12-07 12:39

    I think this would be a better way to do it in Swift:

    func filterContentForSearchText(searchText:NSString, scope:NSString)
    {
       searchResults = recipes.filter { name.rangeOfString(searchText) != nil  }
    }
    

提交回复
热议问题