Skip to content

Instantly share code, notes, and snippets.

"SHINDIG" = "Shindig";
"PROFILE" = "Profile";
"NEXT" = "Next";
"WELCOME_TEXT" = "Shindig helps you organize events and share their best moments with your friends.";
"ENTER_EMAIL" = "Please enter your email address and let's get the party started!";
[scrollView addSubview:({
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
label.text = @"Hello World";
label;
})];
[scrollView addSubview:({
UILabel* label = [[UILabel alloc] initWithFrame:CGRectZero];
label;
})];
+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL {
if (&NSURLIsExcludedFromBackupKey == nil) { // iOS <= 5.0.1
const char* filePath = [[URL path] fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
u_int8_t attrValue = 1;
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
return result == 0;
} else { // iOS >= 5.1
- (void)testWeakAssign
{
SingleThreadLock* condition = [[SingleThreadLock alloc]init];
__block AXProductDescription *p1;
[AXProductDescription getHeroesWithCompletionHandler:^(NSArray *products, NSError *error) {
p1 = [products objectAtIndex:0];
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext
{
if ([self.delegate respondsToSelector:@selector(setAnimating:)])
[self.delegate setAnimating:YES];
UIView* containerView = [transitionContext containerView];
UIViewController* fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController* toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
#import <objc/runtime.h>
#import <objc/message.h>
__attribute__((constructor)) static void PSPDFFixCollectionViewUpdateItemWhenKeyboardIsDisplayed(void) {
@autoreleasepool {
if ([UICollectionViewUpdateItem class] == nil) return; // pre-iOS6.
if (![UICollectionViewUpdateItem instancesRespondToSelector:@selector(action)]) {
IMP updateIMP = imp_implementationWithBlock(^(id _self) {});
Method method = class_getInstanceMethod([UICollectionViewUpdateItem class], @selector(action));
const char *encoding = method_getTypeEncoding(method);
if (!class_addMethod([UICollectionViewUpdateItem class], @selector(action), updateIMP, encoding)) {
@interface __NSSpecialDictionary : NSObject
@end
@implementation __NSSpecialDictionary
@end
@interface NSDictionary (specialDictionaries)
+ (instancetype)specialDictionary;
@end
//
// FRCTheParentViewController.m
// VCDemo
//
// Created by Matthew Wilkinson on 11/06/2013.
// Copyright (c) 2013 FreshCocoa. All rights reserved.
//
#import "FRCTheParentViewController.h"
- (void)swap:(id*)a with:(id*)b
{
id c = *a;
*a = *b;
*b = c;
}
id a = @1;
id b = @2;