Skip to content

Instantly share code, notes, and snippets.

View adriantofan's full-sized avatar

Adrian Tofan adriantofan

View GitHub Profile
@adriantofan
adriantofan / x
Created April 14, 2015 09:43
NSArray
//http://ronnqvi.st/array-intersections-and-differences
NSPredicate *intersectPredicate =
[NSPredicate predicateWithFormat:@"SELF IN %@", otherArray];
NSArray *intersect =
[firstArray filteredArrayUsingPredicate:intersectPredicate];
NSPredicate *relativeComplementPredicate = // a minus b
[NSPredicate predicateWithFormat:@"NOT SELF IN %@", otherArray];
NSArray *relativeComplement =
@adriantofan
adriantofan / gist:bd5af4fd74124f5c50b1
Created March 31, 2015 08:02
self sizing cells iOS 8
self.tableView.estimatedRowHeight = 44.0;
self.tableView.rowHeight = UITableViewAutomaticDimension;
//
cell.textLabel.numberOfLines = 0;
@adriantofan
adriantofan / gist:8c0cfc8872df54446476
Last active August 9, 2016 14:34
show custom fonts family names
for(NSString *fontfamilyname in [UIFont familyNames])
{
if (![fontfamilyname containsString:@"elvetica"]) {
continue;
}
NSLog(@"family:'%@'",fontfamilyname);
for(NSString *fontName in [UIFont fontNamesForFamilyName:fontfamilyname])
{
NSLog(@"\tfont:'%@'",fontName);
}
no separators for empty cells
tableView.tableFooterView = UIView(frame: CGRectZero)
//http://stackoverflow.com/questions/25770119/ios-8-uitableview-separator-inset-0-not-working
// From End To end
cell.separatorInset = UIEdgeInsetsZero;
cell.layoutMargins = UIEdgeInsetsZero;
cell.preservesSuperviewLayoutMargins = NO;
// invisible
@adriantofan
adriantofan / gist:23d01c97a9f47f722495
Created March 6, 2015 08:23
add/remove childviewcontroller
[self addChildViewController:vc];
// [vc willMoveToParentViewController:self] called automatically
[self.view addSubview:vc.view]; // or something like this.
[vc didMoveToParentViewController:self];
// For removing view controllers:
[vc willMoveToParentViewController:nil];
[vc.view removeFromSuperview]; // or something like this
[vc removeFromParentViewController];
NSLocale *locale = [NSLocale currentLocale];
// [locale localeIdentifier] fr_FR (i'm in france)
NSLog(@"current locale: %@", locale.localeIdentifier);
NSArray* preferredLanguages = [NSLocale preferredLanguages];
NSLog(@"preferredLanguages: %@", preferredLanguages);
// en,fr ( the interface is in english )
NSString* code = [locale objectForKey:NSLocaleCurrencyCode];