Skip to content

Instantly share code, notes, and snippets.

View niltoft's full-sized avatar

Pontus Niltoft niltoft

  • Fishbrain
  • Stockholm
View GitHub Profile
@jenshandersson
jenshandersson / JAConcat.m
Created January 5, 2014 20:24
String concatenation in Objective-C, using one line of code. Takes a list of NSObject and concatenates their description.
#define $(...) ((NSString *)[[NSArray arrayWithObjects:__VA_ARGS__, nil] componentsJoinedByString:@""])
/*
* Example
*/
NSString *string = $(@"Hello", @" ", @"World!", @"\n", @"1 + 2 = ", @(1+2));
@jenshandersson
jenshandersson / gist:5721994
Last active December 18, 2015 03:58
A simple way to profile execution time of a code snippet.
static CFAbsoluteTime JAProfilingBlock (void (^block)(void)) {
CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
block ();
CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
return end - start;
}
#example usage