Latest 0.0.2
Homepage https://github.com/Adrian2112/ILRemoteSearchBar
License MIT
Platforms ios , requires ARC
Authors

A UISearchBar subclass that observes the search field on a given frequency.

This is meant to be used to query a remote server after the text on search field is changed without firing the search for each character typed.

The search field fires the delegate method after the user stops writing for an specified time interval.

ILRemoteSearchBar demo

Usage

Install with cocoapods

pod 'ILRemoteSearchBar'

Make your view controller conforms to ILRemoteSearchBarDelegate protocol

@interface ILViewController () <ILRemoteSearchBarDelegate>

Set the search bars delegate to your view controller
(programatically with the viewDidLoad or via interface builder)

ILRemoteSearchBar *searchBar = [[ILRemoteSearchBar alloc] ...];

searchBar.delegate = self;

Add the remoteSearchBar:textDidChange: method to your view controller and call your API from there

# pragma mark - ILRemoteSearchBarDelegate

- (void)remoteSearchBar:(ILRemoteSearchBar *)searchBar
          textDidChange:(NSString *)searchText
{
    // call your api
}

You can even conform to UISearchBarDelegate and receive the delegate
methods for your ILRemoteSearchBar

Warning

If your view controller is conforming to the UISearchBarDelegate the
searchBar:TextDidChange: will be called when your ILRemoteSearchBar
text is changed as ILRemoteSearchBar is a subclass of UISearchBar
so make sure to check that the sender object is not your ILRemoteSearchBar

-(void)searchBar:(UISearchBar *)searchBar
        textDidChange:(NSString *)searchText
{
  if (searchBar != self.myRemoteSearchBar) {
    // do your thing
  }
}

Configuration

You can change the time interval to wait before the delegate method is called with

searchBar.timeToWait = 0.5; // 0.5 is the default value

Author

Adrián González

License

The MIT License (MIT)

Copyright (c) 2013 Adrián González Latest podspec

{
    "name": "ILRemoteSearchBar",
    "version": "0.0.2",
    "summary": "A UISearchBar subclass that observes the search field on a given frequency",
    "description": "                    A UISearchBar subclass that observes the search field on a given frequency.nn                    This is meant to be used to query a remote server after the text on search field is changedn                    without firing the search for each character typed.n                    The search field fires the delegate method after the user stops writing for an specified time interval.n",
    "homepage": "https://github.com/Adrian2112/ILRemoteSearchBar",
    "license": "MIT",
    "authors": {
        "Adriu00e1n Gonzu00e1lez": "[email protected]"
    },
    "platforms": {
        "ios": null
    },
    "source": {
        "git": "https://github.com/Adrian2112/ILRemoteSearchBar.git",
        "tag": "0.0.2"
    },
    "source_files": "ILRemoteSearchBar/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This