Skip to content

Instantly share code, notes, and snippets.

/*
You can use this to call deprecated methods without warnings (supporting old sdk's for example)
or, you can use it in place of performSelector: where you need non-object params, or multiple
params.
*/
- (void)callSelector:(SEL)aSelector returnAddress:(void *)result argumentAddresses:(void *)arg1, ...
{
va_list args;
#import <Foundation/Foundation.h>
#import "to_object.h"
int main (int argc, const char * argv[]) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
const char *str = "wut";
id o = $<const char *>(str);
NSLog(@"char: %s, string: %@, of class: %@", str, o, [o class]);
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if ([[[request URL] scheme] isEqualToString:@"mailto"]) {
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
NSArray *rawURLparts = [[[request URL] resourceSpecifier] componentsSeparatedByString:@"?"];
if (rawURLparts.count > 2) {
return NO; // invalid URL
}
{
"_id": "_design/geojson",
"spatial": {
"points": "function(doc) { emit(doc.geometry, {id: doc._id, geometry: doc.geometry, properties: doc.properties}) };"
}
}
//
// MGSplitViewController.h
// MGSplitView
//
// Created by Matt Gemmell on 26/07/2010.
// Copyright 2010 Instinctive Code.
//
#import <UIKit/UIKit.h>
/*
Copyright (c) 2009 Remy Demarest
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
@haikusw
haikusw / main.m
Created April 25, 2011 06:36
Why I don't like KVC - lets you access private instance variables; breaks OOP encapsulation.
#include <stdio.h>
#include <Foundation/Foundation.h>
// -----
@interface Foo : NSObject
{
@private
NSNumber* bar;
}
@haikusw
haikusw / NSData+CommonDigest.h
Created May 24, 2011 06:45 — forked from 0xced/NSData+CommonDigest.h
NSData+CommonDigest: The most elegant NSData category for cryptographic hash functions
/*
Licensed under the MIT License
Copyright (c) 2011 Cédric Luthi
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
@haikusw
haikusw / HSIDateUtils.h
Created June 1, 2011 21:37
debugging aid for dates
#import <Foundation/Foundation.h>
@interface NSDateComponents (HSINSDateUtils)
- (void) logToConsole;
@end
@haikusw
haikusw / gist:1050447
Created June 28, 2011 03:48
Objective C singleton pattern templates discussion
// Accessorizer's default generated singleton code for class Foo
static Foo *sharedInstance = nil;
+ (void) initialize
{
if (sharedInstance == nil)
sharedInstance = [[self alloc] init];
}