Skip to content

Instantly share code, notes, and snippets.

@CavalcanteLeo
CavalcanteLeo / Directory.h
Created March 22, 2016 02:41 — forked from flipjorge/Directory.h
iOS Directories paths helper
#import <Foundation/Foundation.h>
@interface Directory : NSObject
+(NSString*)documents;
+(NSString*)temp;
+(NSString*)library;
+(NSString*)bundle;
+(NSString*)cache;
+(NSString*)preferences;
// DictionaryTypesHelper.h
#import <Foundation/Foundation.h>
@interface NSDictionary (NSDictionary_DictionaryTypesHelper)
- (NSArray*)arrayForKey:(id)key;
- (NSDictionary*)dictionaryForKey:(id)key;
- (NSString*)stringForKey:(id)key;
- (NSNumber*)numberForKey:(id)key;
- (NSData*)dataForKey:(id)key;
@CavalcanteLeo
CavalcanteLeo / taskHelper.m
Created March 22, 2016 02:47 — forked from craigrbruce/taskHelper.m
Helper class in obj-c to encapsulate bg tasks
@implementation taskHelper {
}
+ (void)runTaskInBackground:(void (^)())backgroundTask
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), backgroundTask);
}
+ (void)runTaskInForeground:(void (^)())foregroundTask
@CavalcanteLeo
CavalcanteLeo / GCDManager.h
Created March 22, 2016 02:49 — forked from shyambhat/GCDManager.h
Clean Objective C helper methods to perform background tasks and perform completion on main thread.
#import <Foundation/Foundation.h>
@interface GCDManager : NSObject
+ (void)performBackgroundTask:(void (^)())block withCompletion:(void (^)())completion;
+ (void)performHighPriorityBackgroundTask:(void (^)())block withCompletion:(void (^)())completion;
+ (void)performLowPriorityBackgroundTask:(void (^)())block withCompletion:(void (^)())completion;
@end
@CavalcanteLeo
CavalcanteLeo / YMKeyboardLayoutHelperView.m
Created March 22, 2016 02:50 — forked from shepting/YMKeyboardLayoutHelperView.m
A great little helper for handling keyboard animations nicely. Just put this view at the bottom vertically of your views and it will move everything else up and down for you.
//
// YMKeyboardLayoutHelperView.m
// ios-chat
//
// Created by Steven Hepting on 7/17/13.
// Copyright (c) 2013 Yammer. All rights reserved.
//
#import "YMKeyboardLayoutHelperView.h"
#import "UIView+LayoutAdditions.h"
@CavalcanteLeo
CavalcanteLeo / Helper.m
Created March 22, 2016 02:52 — forked from nicroth/Helper.m
iOS - Resize a UIImage - actually resizes the data for uploading!
//takes an image, and returns a dictionary with multiple sizes
-(NSDictionary *)resizeImage:(UIImage *)theImage
{
//Create the "large" size image to upload
float actualHeight = theImage.size.height;
float actualWidth = theImage.size.width;
float imgRatio = actualWidth/actualHeight;
//set the maximum size you want - width/height
float maxRatio = 640.0/960.0;
//determine the required size to use
@CavalcanteLeo
CavalcanteLeo / ColorHelper.h
Created March 22, 2016 02:54 — forked from hmcfletch/ColorHelper.h
A bunch of objective-c color helpers
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
// generate a UIColor from rgb and alpha values
#define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define RGB(r, g, b) RGBA(r, g, b, 1.0)
// generate a UIColor
#define GRAYSCALEA(rgb, a) RGBA(rgb, rgb, rgb, a)
#define GRAYSCALE(rgb) GRAYSCALEA(rgb, 1.0)
// generate a UIColor from a hex and an alpha value
@CavalcanteLeo
CavalcanteLeo / SnapshotHelper.h
Created March 22, 2016 02:55 — forked from vovkasm/SnapshotHelper.h
Objective C implementation of SnapshotHelper class for https://github.com/fastlane/snapshot
/* This SnapshotHelper class should be compatible with SnapshotHelper.swift version 1.2 */
@import Foundation;
@import XCTest;
@interface SnapshotHelper : NSObject
- (instancetype)initWithApp:(XCUIApplication*)app;
- (void)snapshot:(NSString*)name waitForLoadingIndicator:(BOOL)wait;
#import <Foundation/Foundation.h>
#import "Image.h"
@interface ImageHelper : NSObject{
@private
Image *image;
}
- (UIImage *)getThumbnailImage;
- (UIImage *)getFullScreenImage;
- (UIImage *)getOriginalImage;
#import "ImageHelper.h"
#import "EntryHelper.h"
@implementation ImageHelper
@synthesize image;
- (UIImage *)getFullScreenImage{
return [UIImage imageWithContentsOfFile:[self getFullScreenImagePath]];
}