Skip to content

Instantly share code, notes, and snippets.

View danielctull's full-sized avatar

Daniel Tull danielctull

View GitHub Profile
- (NSUInteger)supportedInterfaceOrientations {
switch ([[UIDevice currentDevice] userInterfaceIdiom]) {
case UIUserInterfaceIdiomPad:
return UIInterfaceOrientationMaskLandscape;
case UIUserInterfaceIdiomPhone:
return UIInterfaceOrientationMaskPortrait;
}
git log --pretty=format:"* %s" --reverse 567..HEAD
+ (void)checkToDisplayConnectionAlert {
static BOOL hasAlerted = NO;
BOOL canConnect = ([[DLMHTTPClient sharedClient] networkReachabilityStatus] == AFNetworkReachabilityStatusReachableViaWWAN | [[DLMHTTPClient sharedClient] networkReachabilityStatus] == AFNetworkReachabilityStatusReachableViaWiFi);
if (canConnect) {
hasAlerted = NO;
} else if (!hasAlerted) {
@danielctull
danielctull / DCTPropertyNameFromSelector.h
Created January 22, 2013 21:52
Category to give you the name of a property from a selector, will assert that the property exists.
#import <Foundation/Foundation.h>
@interface NSObject (DCTPropertyNameFromSelector)
- (NSString *)dct_propertyNameForSelector:(SEL)selector;
@end
@danielctull
danielctull / RQSTextFieldOptionsController.h
Created January 14, 2013 10:50
Controller that displays a picker view as an input view to a text field on iPhone or in a popover on iPad.
//
// RQSTextFieldOptionsController.h
// Requests
//
// Created by Daniel Tull on 03.10.2012.
// Copyright (c) 2012 Daniel Tull. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
NSArray *array = @[@"one", @"two", @"three", @"four", @"five", @"six", @"seven", @"eight", @"nine", @"ten", @"eleven", @"twelve"];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0);
dispatch_group_t group = dispatch_group_create();
dispatch_semaphore_t semaphore = dispatch_semaphore_create(6);
@danielctull
danielctull / ActivityController.h
Created December 13, 2012 13:56
A controller object that presents an activity view controller either modally or in a popover depending on the platform. It associates the created controller object with the activity view controller or popover controller, so that when either are dismissed, all the associations are removed. This way if you hold only a *weak* reference to the retur…
#import <UIKit/UIKit.h>
@interface ActivityController : NSObject
+ (instancetype)presentActivityItems:(NSArray *)activityItems
fromViewController:(UIViewController *)viewController
barButtonItem:(UIBarButtonItem *)item;
@end
@danielctull
danielctull / ShakeAnimation.m
Created September 7, 2012 16:14 — forked from pieteromvlee/ShakeAnimation.m
ShakeAnimation; a variant on @danielctull's versopm
@implementation ShakeAnimation {
CGRect originalRect;
NSInteger counter;
}
+ (void)shakeView:(UIView *)view {
[[[[self class] alloc] initWithView:view] shake];
}
- (id)initWithView:(UIView *)view {
@danielctull
danielctull / GlobalSettings.plist
Created August 7, 2012 14:48 — forked from samdeane/GlobalSettings.plist
Script for generating appledoc docs
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>--project-company</key>
<string>Elegant Chaos</string>
<key>--company-id</key>
<string>com.elegantchaos</string>
<key>--keep-undocumented-objects</key>
<false/>
@danielctull
danielctull / ThreadedManagedObjectContext.h
Created July 25, 2012 14:04
NSManagedObjectContext for iOS 4. Maybe?
/*
ThreadedManagedObjectContext.h
ThreadedManagedObjectContext
Created by Daniel Tull on 25.07.2012.
Copyright (c) 2012 Daniel Tull. All rights reserved.