Skip to content

Instantly share code, notes, and snippets.

@astralbodies
astralbodies / CoreDataStack.swift
Last active November 29, 2022 14:13
Ray Wenderlich Core Data Stack & Iterative Migrator
/// Copyright (c) 2019 Razeware LLC
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
@astralbodies
astralbodies / insights.diff
Last active May 19, 2017 14:57
Stats overrides for snapshots
[2] $ diff InsightsTableViewController.m ~/src/WordPressCom-Stats-iOS/WordPressCom-Stats-iOS/UI/InsightsTableViewController.m -u ✘∞ ∞
--- InsightsTableViewController.m 2017-05-19 09:23:22.000000000 -0500
+++ /Users/aaron/src/WordPressCom-Stats-iOS/WordPressCom-Stats-iOS/UI/InsightsTableViewController.m 2016-12-14 11:16:23.000000000 -0600
@@ -1149,20 +1149,11 @@
{
if (summary) {
weakSelf.sectionData[@(StatsSectionInsightsTodaysStats)] = summary;
- summary.views = @"65";
- summary.visitors = @"58";
- summary.likes = @"12";
@astralbodies
astralbodies / Person.swift
Created May 3, 2017 00:49
Vicki Loves Jorge
class Person {
let name: String
var loves: Person?
init(_ name: String) {
self.name = name
}
func loves(_ who: Person) {
loves = who
- (void)keyboardControls:(BSKeyboardControls *)keyboardControls selectedField:(UIView *)field inDirection:(BSKeyboardControlsDirection)direction
{
AppointmentDetailEditCell *cell = (AppointmentDetailEditCell *)keyboardControls.activeField.superview.superview;
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:cell.center];
NSLog(@"Scroll to: %@ for cell: %@ and field: %@", indexPath, cell, field);
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
}
- (void)keyboardControls:(BSKeyboardControls *)keyboardControls selectedField:(UIView *)field inDirection:(BSKeyboardControlsDirection)direction
{
AppointmentDetailEditCell *cell = (AppointmentDetailEditCell *)keyboardControls.activeField.superview.superview;
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:cell.center];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
double delayInSeconds = 0.2;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
2013-03-06 09:27:40.748 PowerPlay[11962:c07] Scroll to: <NSIndexPath 0xcab9230> 2 indexes [1, 0] for cell: <AppointmentDetailEditCell: 0xc90d050; baseClass = UITableViewCell; frame = (0 140; 512 46); text = 'Name'; autoresize = W; layer = <CALayer: 0xc90d1b0>> and field: <UITextField: 0xc90cba0; frame = (266 12; 183 19); text = 'Santa-Maria'; clipsToBounds = YES; opaque = NO; autoresize = LM+W; tag = 1; gestureRecognizers = <NSArray: 0xc915090>; layer = <CALayer: 0xc90ccf0>>
2013-03-06 09:27:41.130 PowerPlay[11962:c07] Scroll to: <NSIndexPath 0x12bc09e0> 2 indexes [3, 0] for cell: <AppointmentDetailEditCell: 0xc9215f0; baseClass = UITableViewCell; frame = (0 351; 512 45); text = 'Address 1'; autoresize = W; layer = <CALayer: 0xc921750>> and field: <UITextField: 0xc921e80; frame = (83 12; 350 19); text = '134 cc way'; clipsToBounds = YES; opaque = NO; autoresize = W; tag = 2; gestureRecognizers = <NSArray: 0xc922410>; layer = <CALayer: 0xc921fd0>>
2013-03-06 09:27:41.525 PowerPlay[11962:c07] Scroll to: <NSInde
@astralbodies
astralbodies / gist:3226628
Created August 1, 2012 12:54
Scroll to the search bar when tapping the magnifying glass
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
if (index == 0) {
CGRect searchBarFrame = self.searchDisplayController.searchBar.frame;
[tableView scrollRectToVisible:searchBarFrame animated:NO];
return -1;
}
return index;
}
@astralbodies
astralbodies / gist:3226609
Created August 1, 2012 12:51
Add search magnifying glass to a UITableView
[array insertObject:UITableViewIndexSearch atIndex:0];
@astralbodies
astralbodies / TransitionController.h
Created July 9, 2012 18:24 — forked from xjones/TransitionController.h
TransitionController for animating iOS view controller transitions w/o a controller stack
//
// TransitionController.h
//
// Created by XJones on 11/25/11.
//
#import <UIKit/UIKit.h>
@interface TransitionController : UIViewController
@astralbodies
astralbodies / gist:2394164
Created April 15, 2012 18:03
Unload 1Password agent
launchctl unload -w ~/Library/LaunchAgents/ws.agile.1PasswordAgent.plist