Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use predicate in ios

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 427
    Comment on it

    In iOS we can use Predicates in order to get fast response. Mostly iOS developers use Predicates in search functionality to filter it as user types in search bar textfield.

    Let suppose you have an array named as youDataArray which contains string data and you want to apply filter using Predicate then take another array named as filteredArray

    I'm taking searchText as a search bar textfield here.

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self CONTAINS[cd] %@",searchText];
        filteredArray = [youDataArray filteredArrayUsingPredicate:predicate] ;
    

    There are several predicate formats. Hope this will help.

    Happy Coding!!!

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: