Skip to content

Instantly share code, notes, and snippets.

<table width="100%" border="1" cellpadding="60">
<tr>
<td>One</td>
<td>Two</td>
<td>Three Three Three Three Three Three Three Three Three Three Three Three Three Three Three Three Three Three</td>
</tr>
</table>
// Given a set of NSManagedObjects, return those objects in this managed object context
-(NSMutableSet*)objectsInSet:(NSSet*)objects {
NSMutableSet *newSet = [NSMutableSet set];
for (NSManagedObject* object in objects) {
[newSet addObject:[self objectWithID:object.objectID]];
}
return newSet;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
NSString *foo =
//123456789012345678901234567890
@"##############################";
SEL methodSel = NSSelectorFromString(methodStr);
if ([self respondsToSelector:methodSel])
{
#pragma clang diagnostic warning push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self performSelector:methodSel];
#pragma clang diagnostic warning pop
}
@steveriggins
steveriggins / gist:5258032
Created March 27, 2013 21:10
sharedInstance appCode live template
+ ($class$ *)sharedInstance {
static dispatch_once_t onceQueue;
static $class$ *$var$ = nil;
dispatch_once(&onceQueue, ^{
$var$ = [[self alloc] init];
});
return $var$;
}
@steveriggins
steveriggins / gist:5259496
Created March 28, 2013 00:32
Special Style Guide for code that is to be reviewed by Tim
- (BOOL)cmpObjAddr:(id)objAddr otherObj:(id)objOtherAddr
{
int cVar = (int)objAddr;
int dVar = (int)objOtherAddr;
if (cVar != dVar) {
char c = *(char *)(cVar);
cVarModifier(c);
}
@steveriggins
steveriggins / gist:5393379
Created April 16, 2013 04:37
It's All About The Benjamins
tell application "Messages"
set allTheBens to every buddy whose id contains "benacker@gmail.com"
set ben to item 1 of allTheBens
send "hey" to ben
end tell
@steveriggins
steveriggins / gist:6652508
Last active December 23, 2015 14:59
iOS 7 has a bug (or made a design decision which goes against the documentation) to set the cookie policy of NSURLConnections to whatever the user has set their cookie preferences to via Settings -> Safari. This simple method resets the cookie policy to accept always. Apple documentation for cookieAcceptPolicy: https://developer.apple.com/librar…
- (void)takeControlOfTheCookies
{
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self takeControlOfTheCookies];
@steveriggins
steveriggins / gist:8486943
Last active January 3, 2016 16:08
Simple label in a viewController's view
- (void)viewDidLoad
{
[super viewDidLoad];
self.listPriceLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
self.listPriceLabel.backgroundColor = [UIColor yellowColor];
[self.view addSubview:self.listPriceLabel];
[self.listPriceLabel sizeToFit];
self.listPriceLabel.text = @"Hello World";