Skip to content

Instantly share code, notes, and snippets.

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSIndexPath *selectedRowIndexPath = [self.tableView indexPathForSelectedRow];
if (selectedRowIndexPath) {
[self.tableView deselectRowAtIndexPath:selectedRowIndexPath animated:YES];
[[self transitionCoordinator] notifyWhenInteractionEndsUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> context) {
if ([context isCancelled]) {
[self.tableView selectRowAtIndexPath:selectedRowIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
@seivan
seivan / 0_reuse_code.js
Created January 30, 2014 13:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Pod::Spec.new do |s|
name = "PLCrashReporter"
version = "1.2-rc2"
s.name = name
s.version = version
s.summary = "Reliable, open-source crash reporting for iOS and Mac OS X."
s.description = <<-DESC
Plausible CrashReporter provides an in-process crash reporting

(Also posted to hacker news, if you find it useful and thing others would, up vote it there: https://news.ycombinator.com/item?id=7043450)

Hi Jonathan,

My name is XXXX. I currently work at XXXX, but have been building apps on the side for the past few years, and have my first tech & iOS engineering interview in a few weeks. I’ve looked up to you and your work for quite a while, and was wondering if you had any tips or advice.

@seivan
seivan / then.m
Created August 15, 2013 14:59 — forked from tonyarnold/then.m
self.currentlyLoggingIn = NO;
self.didLoginSubject = [RACSubject subject];
self.loginCommand = [RACCommand commandWithCanExecuteSignal:[RACSignal
combineLatest:@[self.usernameTextField.rac_textSignal,
self.passwordTextField.rac_textSignal,
RACObserve(self, currentlyLoggingIn)]
reduce:^(NSString *username, NSString *password, NSNumber *currentlyLoggingIn) {
return @(username.length > 0 && password.length > 0 && NO == currentlyLoggingIn.boolValue );
}]];

Rule 0: Do not make a framework.

Ask yourself if you should be making a framework given that you are not in the business of making frameworks. Believe it or not, most of us have the urge to solve problems completely and in the general case as our first inclination, but getting things done requires not doing so almost all of the time.

Rule 1: Do not have dependencies on other 3rd party frameworks.

Frameworks should be modular and standalone. They should require nothing but the standard system libraries in order to run. If the framework relies on other functionality, it should encompass it entirely. If it cannot, it probably violates Rule 3.

Rule 2: Use a non-viral open-source license like MIT or Apache, NOT GPL.

TLDR
If you want the simplest option just start /** [content] */ slashes in your header files. Do it before the @implementation for class comments and above methods for method documentation.
Doing this is the minimal for support in LLVM and Appledoc, which means you get CocoaDocs & XCode support.
Not TLDR
Good examples:
https://github.com/marcransome/MRBrew/blob/master/MRBrew/MRBrew.h
https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking/AFHTTPClient.h
//
// UIImage+vImageScaling.h
// UIImage+vImageScaling
//
// Created by Matt Donnelly on 03/07/2013.
// Copyright (c) 2013 Matt Donnelly. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <pthread.h>
static void unsafe_signal_handler (int signo) {
/* Try to fetch thread names with the pthread API */
char name[512];
NSLog(@"Trying to use the pthread API from a signal handler. Is a deadlock coming?");
pthread_getname_np(pthread_self(), name, sizeof(name));
// We'll never reach this point. The process will stop here until the OS watchdog
// kills it in 20+ seconds, or the user force quits it. No crash report (or a partial corrupt
#define MSDesignatedInitializer(__SEL__) __attribute__((unavailable("Invoke the designated initializer `" # __SEL__ "` instead.")))
// Sample usage:
- (id)initWithObject:(id)object;
- (id)init MSDesignatedInitializer(initWithObject:); // <- This even gets auto-complete.
// Now calling init on this class would throw a warning.