This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSMutableArray+Stack.h | |
// shell poc | |
// | |
// Created by Jose Luis Campaña on 9/18/12. | |
// Copyright (c) 2012 Jose Luis Campaña. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSMutableArray+Stack.m | |
// shell poc | |
// | |
// Created by Jose Luis Campaña on 9/18/12. | |
// Copyright (c) 2012 Jose Luis Campaña. All rights reserved. | |
// | |
#import "NSMutableArray+Stack.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//We need some properties | |
@property (nonatomic,strong) NSMutableArray *dataSource; | |
@property (nonatomic, strong) UITextField *currentTextField; | |
@property (nonatomic) CGRect originalTableFrame; | |
@property (nonatomic) NSIndexPath *indexForCurrentTextField; | |
@property (nonatomic) NSTimeInterval keyboardAnimationDuration; | |
//Don't forget to be delegate of UITextFieldDelegate | |
//Then... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (CGPoint)getMostLeftTransparentPixelOfImage:(UIImage*)image | |
{ | |
int xx = 0; | |
int yy = 0; | |
int count = image.size.width * image.size.height; | |
// First get the image into your data buffer | |
CGImageRef imageRef = [image CGImage]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (CGPoint)getFirstTransparentPixelOfImage:(UIImage*)image | |
{ | |
int xx = 0; | |
int yy = 0; | |
int count = image.size.width * image.size.height; | |
// First get the image into your data buffer | |
CGImageRef imageRef = [image CGImage]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+(NSString *)getTimeAgo:(NSDate *)fecha | |
{ | |
NSString *timeAgo; | |
float since_mins,since_hours, since_days, since_months, since_years; | |
NSTimeInterval since = fabs([fecha timeIntervalSinceNow]); | |
since_mins = (since / 60); | |
since_hours = (since_mins / 60); | |
since_days = (since_hours / 24); | |
since_months = (since_days / 31); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+(BOOL)orientationIsPortrait | |
{ | |
return UIDeviceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]); | |
} | |
+ (UIInterfaceOrientation) interfaceOrientation | |
{ | |
return [[UIApplication sharedApplication] statusBarOrientation]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+(natural_t) getFreeMemory | |
{ | |
mach_port_t host_port; | |
mach_msg_type_number_t host_size; | |
vm_size_t pagesize; | |
host_port = mach_host_self(); | |
host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t); | |
host_page_size(host_port, &pagesize); | |
vm_statistics_data_t vm_stat; | |
if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+(NSInteger)getRandomIntBetween:(NSInteger)min andMax:(NSInteger)max | |
{ | |
return min + arc4random() % ((max + 1) - min); | |
} |