Skip to content

Instantly share code, notes, and snippets.

View jonfriskics's full-sized avatar

Jon Friskics jonfriskics

View GitHub Profile
extension CLLocationCoordinate2D: Equatable {}
extension Double {
func places(p: Double) -> String {
return NSString(format: "%\(p)f", self)
}
}
public func ==(lhs: CLLocationCoordinate2D, rhs: CLLocationCoordinate2D) -> Bool {
return lhs.latitude.places(3) == rhs.latitude.places(3) && lhs.longitude.places(3) == rhs.longitude.places(3)
func anyCommonElements <T, U where T: Sequence, U: Sequence, T.GeneratorType.Element: Equatable, T.GeneratorType.Element == U.GeneratorType.Element> (lhs: T, rhs: U) -> Bool {
for lhsItem in lhs {
for rhsItem in rhs {
if lhsItem == rhsItem {
return true
}
}
}
return false
}
@jonfriskics
jonfriskics / AVRAnimatedTableViewCell.h
Last active August 29, 2015 14:00
Animations that persist in cells (sort of)
//
// AVRAnimatedTableViewController.m
// AnimationIssues
//
// Created by Adam Weeks on 5/2/14.
// Copyright (c) 2014 AppsVersusRobots, LLC. All rights reserved.
//
#import "AVRAnimatedTableViewController.h"
#import "AVRAnimatedTableViewCell.h"
@jonfriskics
jonfriskics / gist:11373716
Last active August 29, 2015 14:00
Making NSArray.count not throw an implicit signedness error when calling the tableView:numberOfRowsInSection: method
#import "TableViewController.h"
@interface NSArray (CountForTableView)
- (NSInteger)countForTableView;
@end
@implementation NSArray (CountForTableView)
@jonfriskics
jonfriskics / MapViewController.h
Last active September 6, 2018 12:21
Custom info window that can be interacted with using the Google Maps SDK for iOS
//
// MapViewController.h
// MapsCustomInfoWindow
//
// Created by Jon Friskics on 4/22/14.
// Copyright (c) 2014 Jon Friskics. All rights reserved.
//
#import <UIKit/UIKit.h>
@jonfriskics
jonfriskics / gist:9360674
Created March 5, 2014 03:34
UIImagePickerController tints
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
// for light navigation item text, or UIBarStyleDefault for dark navigation item text
imagePickerController.navigationBar.barStyle = UIBarStyleBlack;
// the actual color will be affected by the translucency setting
imagePickerController.navigationBar.barTintColor = [UIColor blueColor];
// default is YES, but you could change to NO
imagePickerController.navigationBar.translucent = YES;
@jonfriskics
jonfriskics / AppDelegate.m
Last active December 25, 2015 17:39
UIPageViewController example - demo of the pageViewController not interfering with touches on the child VCs.
#import "AppDelegate.h"
#import "ContainerVC.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [[ContainerVC alloc] init];
@jonfriskics
jonfriskics / gist:6896230
Created October 9, 2013 04:29
UITextView and the keyboard
[[NSNotificationCenter defaultCenter] addObserverForName:@"UIKeyboardDidShowNotification" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
CGRect cursorRect = [self.textView caretRectForPosition:self.textView.selectedTextRange.start];
if(CGRectGetMaxY(cursorRect) > CGRectGetHeight(self.view.frame) - self.topLayoutGuide.length - 216) {
[UIView animateWithDuration:1.0f animations:^{
self.textView.contentOffset = CGPointMake(0, 216);
} completion:^(BOOL finished) {
}];
}
}];
@jonfriskics
jonfriskics / AppDelegate.h
Last active December 19, 2015 07:59
Using AFNetworking to query an API endpoint in the AppDelegate before any view controllers appear
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
@jonfriskics
jonfriskics / ViewController.h
Created July 2, 2013 05:03
AFNetworking GET and POST example
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) UILabel *getResponseLabel;
@property (strong, nonatomic) UILabel *postResponseLabel;
@end