Skip to content

Instantly share code, notes, and snippets.

View danielctull's full-sized avatar

Daniel Tull danielctull

View GitHub Profile
@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
#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 / 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>
@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
+ (void)checkToDisplayConnectionAlert {
static BOOL hasAlerted = NO;
BOOL canConnect = ([[DLMHTTPClient sharedClient] networkReachabilityStatus] == AFNetworkReachabilityStatusReachableViaWWAN | [[DLMHTTPClient sharedClient] networkReachabilityStatus] == AFNetworkReachabilityStatusReachableViaWiFi);
if (canConnect) {
hasAlerted = NO;
} else if (!hasAlerted) {
git log --pretty=format:"* %s" --reverse 567..HEAD
- (NSUInteger)supportedInterfaceOrientations {
switch ([[UIDevice currentDevice] userInterfaceIdiom]) {
case UIUserInterfaceIdiomPad:
return UIInterfaceOrientationMaskLandscape;
case UIUserInterfaceIdiomPhone:
return UIInterfaceOrientationMaskPortrait;
}
@protocol SnapshotCancellation
- (void)cancel;
@end
+ (id<SnapshotCancellation>)snapshotOfFolder:(NSString*)folder withBlock:(void(^)(Snapshot* shot))block {
Snapshot* s = [[Snapshot alloc] initWithFolder:folder];
[s scanWithCompletion:block];
return s;
fetchRequest.entity = [RNPFeedListEntry entityInManagedObjectContext:self.managedObjectContext];
// this is the main predicate to get the feed entries that belong to the us
NSPredicate *ownerPredicate = [NSPredicate predicateWithFormat:@"%K == %@ AND %K.%K == %@",
RNPFeedListEntryRelationships.owner, self, RNPFeedListEntryRelationships.feed,
RNPFeedAttributes.action, @(FeedAction_LIKE), self];
// this is the predicate to check that we have the required item
NSPredicate *itemPopulatedPredicate = [NSPredicate predicateWithFormat:@"(%K.%K == nil) OR (%K.%K != nil)",
RNPFeedListEntryRelationships.feed, RNPFeedAttributes.itemId,
RNPFeedListEntryRelationships.feed, RNPFeedRelationships.item];
fetchRequest.predicate = [NSCompoundPredicate andPredicateWithSubpredicates:@[ownerPredicate, itemPopulatedPredicate]];
echo "Starting Tag and upload to TestFlight with configuration: ${CONFIGURATION}"
if [[ ${CONFIGURATION} != "Release" ]]; then
exit
fi
cd ${SRCROOT}
PREVIOUSTAG=`git tag | grep "$s." | sort -r | head -1`
TAG="s.`git log --oneline | wc -l | tr -d ' '`"