Skip to content

Instantly share code, notes, and snippets.

View iosdevzone's full-sized avatar

idz iosdevzone

View GitHub Profile
@iosdevzone
iosdevzone / icons.rb
Created June 7, 2013 03:08
A ruby script to produce an Objective C literal from the information in FontAwesome's icons.yml file.
#
# Ruby Script to convert FontAwesome
# glyph information into Objective-C literals
# (Ends up being a big array of NSDictionary objects)
# Output is to stdout. Assumes icons.yml is in working directory.
# Copyright (c) 2013 iOSDeveloperZone.com
# MIT license -- See: http://opensource.org/licenses/MIT
require 'yaml'
#
@iosdevzone
iosdevzone / gist:5676451
Created May 30, 2013 08:17
Leveraging the preprocessor to lessen boilerplate. L(X) is the crux. It allows the me to apply different transformations over the same list.
#define S(_s) @selector(application##_s:) // selector generator
#define N(_n) UIApplication##_n##Notification // name generator
#define L(X) X(WillResignActive), X(DidEnterBackground), \
X(WillEnterForeground), X(DidBecomeActive), X(WillTerminate) // apply X over list
#define C(_a) sizeof((_a))/sizeof((_a)[0]) // array count
- (void)monitorAppState:(BOOL)start
{
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];