Skip to content

Instantly share code, notes, and snippets.

@implementation AppDelegate
{
UITextView *_textView;
}
@synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
alias build='xcodebuild -scheme "SUBSTITUTEYOUROWNSCHEME"'
alias buildfiltered='build | grep -w '\''warning\|error\|BUILD FAILED\|BUILD SUCCEEDED'\'' | grep -v '\''\-\-warning'\'''
alias clean='build clean'
Before @autoreleasepool a fairly common pattern in a try catch would be the following
NSAutoreleasePool *aPool = [[NSAutoreleasePool alloc] init];
@try {
}
@catch (NSException *anException) {
}
@finally {
struct block_literal {
void *isa;
int flags;
int reserved;
void (*invoke)(void *);
void *descriptor;
void *byref_obj;
};
void foo(void)
@rustle
rustle / WeakExternCrash.m
Created September 15, 2012 02:04
Weak linking with extern NSString *const issue
#import <Social/Social.h>
/* Compiled with iOS 6 SDK
* Social.framework weak linked (Optional)
* Run on iOS 5.1 (simulator and device)
*/
// http://simx.me/technonova/software_development/checking_for_weak_linked_frameworks.html
//http://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html#//apple_ref/doc/uid/20002378-106633-CJBGFCAC
//
// NSNotificationCenter+RSLAdditions.h
//
// Created by Doug Russell
// Copyright (c) 2012 Doug Russell. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
@rustle
rustle / gist:4342288
Created December 20, 2012 01:31
Tower with Kaleidoscope 2 beta

Due to a change in Kaleidoscope 2, Tower 1.4.14 does not work with the latest beta of Kaleidoscope 2 (Build 99 and up) out of the box. We are working with the fine folks at Tower to address this issue.

If you are running 1.4.14, download this script and follow the included instructions:

Kaleidoscope Merge Tool

Future versions of Tower should work as expected without the need for these steps.

Builds and runs no problem:

@interface Foo : NSObject
@property (readonly) id foo;
@end

@implementation Foo

- (instancetype)init
@rustle
rustle / gist:4678755
Created January 31, 2013 00:28
Couple of typedefs that I think make the NSFilePresenter block APIs a little easier to read
typedef void (^FilePresenterReacquirerBlock)(void);
typedef void (^FilePresenterReaderBlock)(FilePresenterReacquirerBlock reacquirer);
typedef void (^FilePresenterWriterBlock)(FilePresenterReacquirerBlock reacquirer);
typedef void (^FilePresenterCompletionHandler)(NSError *errorOrNil);
- (void)relinquishPresentedItemToReader:(FilePresenterReaderBlock)reader
{
// Do stuff here ahead of reading
reader(^{
// Do stuff here after reading is done
@rustle
rustle / gist:5017569
Last active December 14, 2015 02:59
Example of an NSValue subclass with a return value on getValue:
#import <Foundation/Foundation.h>
@interface RSTLValue : NSValue
- (BOOL)getValue:(void *)value expectedSize:(size_t)expectedSize;
@end
struct Foo {
NSUInteger i;
char * bar;
};