searchbar - Search Bar - filtering numeric value in swift -
i trying find out how filter table view info based on numeric value entered in search bar. illustration have table view list of persons , want display persons around 20 years of age.....any help much appreciated
i search numeric values advised rajeev converting string double. below code. func filtercontentforsearchtext (searchtext : string) {
var searchnumber = nsnumberformatter().numberfromstring(searchtext)?.doublevalue filteredcandies = candies.filter({ (candy : candy) -> bool in candy.cal < searchnumber })
}
it working <, == , > filtering. ultimate aim search info range between 0.9 x of entered value 1.1 x of entered value. when add together arithmetic operation searchnumber (say 0.9*searchnumber) getting error "double? unwrapped". , if disclose compilation error going while running touch search bar programme exists , says "fatal error: unexpectedly found nil while unwrapping optional value". help on solving much appreciated
follow link , add together search bar above table view
http://www.raywenderlich.com/76519/add-table-view-search-swift
in shouldreloadtableforsearchstring
delegate method, search string user has entered. help enable numeric keypad. convert number , filter out model separate collection. after this, in cellforrowatindexpath , numberofrows methods, homecoming values of collection depending on table view active
swift searchbar
No comments:
Post a Comment