Skip to content

Instantly share code, notes, and snippets.

@lborsato
lborsato / onename
Created July 23, 2015 21:32
onename gist
Verifying I am +lborsato on my passcard. https://onename.com/lborsato
@lborsato
lborsato / createTabController
Last active August 29, 2015 14:11
iOS - Create tab controller with view controllers
// Create a tabbar controller and an array to contain the view controllers
UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate = self;
NSMutableArray *localViewControllersArray = [[NSMutableArray alloc] init];
// Setup first view and nav controllers
UIViewController *vc1 = [[UIViewController alloc] init];
UINavigationController *nc1 = [[UINavigationController alloc] initWithRootViewController:vc1];
[localViewControllersArray addObject:nc1];
@lborsato
lborsato / UITextFieldDelegates
Created December 4, 2014 20:02
iOS UITextField Delegate methods to animate view frames up and down on keyboard appearance/disappearance
#pragma mark - Text Editing functions
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
@lborsato
lborsato / httpPostRequest
Created December 4, 2014 19:40
iOS HTTP Post request
/**
* Do an HTTP POST request and return the results
*
* @param NSString * url the URL
* @param NSString * post the POST data
*
* @return NSDictionary * a dictionary containing the response, error, and data
*/
+ (NSDictionary *)httpPostRequestWithUrl:(NSString *)url post:(NSString *)post
{
@lborsato
lborsato / searchBarDelegate
Created December 4, 2014 16:31
iOS SearchBar Delegate code in Objective-C
#pragma mark - SearchBar delegate methods
- (void) doSearch:(NSString *)searchText {
[self.filteredEntries removeAllObjects];
if ( [searchText length] == 0 ) {
[self.filteredEntries addObjectsFromArray:self.entries];
} else {
for (NSDictionary *entry in self.entries) {
NSString *name = (NSString *)[entry objectForKey:@"fullName"];