Skip to content

Instantly share code, notes, and snippets.

View HeidiHansen's full-sized avatar
🚲

JungleDev HeidiHansen

🚲
View GitHub Profile
@HeidiHansen
HeidiHansen / PeopleInit
Created September 8, 2014 03:08
Designated Initializers
- (instancetype)init
{
return [self initWithName:@""];
}
- (instancetype)initWithName:(NSString *)name
{
return [self initWithName:name
Gender:YES
AgeIs:@9
@HeidiHansen
HeidiHansen / PeopleRandom
Created September 8, 2014 03:10
Arc4Random Function
#define ARC4RANDOM_MAX 0x100000000
- (CGFloat)randomFloatBetweenNumber:(CGFloat)minRange
andNumber:(CGFloat)maxRange
{
return ((float)arc4random() / ARC4RANDOM_MAX) * (maxRange - minRange) + minRange;
}
@HeidiHansen
HeidiHansen / PeopleGrow
Created September 8, 2014 03:23
Nested Control Statements
- (void)grow
{
if (self.isFemale){
if ([self.age integerValue] < 11){
self.height = @([self.height floatValue] + [self randomFloatBetweenNumber:0 andNumber:1]);
}
else if ([self.age integerValue] >= 11 && [self.age integerValue] <= 15){
@HeidiHansen
HeidiHansen / PeopleNSArrayMethods
Created September 8, 2014 04:11
NSArray Methods
- (NSString *)generatePartyList
{
NSMutableArray *partyNamesArray = [[NSMutableArray alloc]init];
for (Person *friend in self.friends){
[partyNamesArray addObject:friend.name];
}
return [partyNamesArray componentsJoinedByString:@", "];
@HeidiHansen
HeidiHansen / PropertiesArrayOfDictionaryValuesFromAPI
Created September 12, 2014 20:06
Extracting titles from an array of book dictionaries
- (void)viewDidLoad
{
[super viewDidLoad];
NSMutableArray *arrayOfBooks = [[NSMutableArray alloc]init];
[MPSAPI getBookLibrary:^(NSArray *books) {
for (NSMutableDictionary *book in books) {
@HeidiHansen
HeidiHansen / 03. THCameraButton drawRect
Last active August 29, 2015 14:06
THCameraButton.m drawRect method. Custom drawn camera button, iOS 7 default camera button look-alike.
#define DegreesToRadians(x) ((x) * M_PI / 180.0)
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGMutablePathRef path = CGPathCreateMutable();
CGFloat buttonRadius = rect.size.width/2;
CGFloat buttonRing = buttonRadius - (buttonRadius/5.5);
@HeidiHansen
HeidiHansen / 01. THFilterViewController.h
Last active August 29, 2015 14:06
Image FilterViewController.h
#import <UIKit/UIKit.h>
#import "FISFilterObject.h"
#import "THConversationShareViewController.h"
@interface FISViewController : UIViewController<UIPickerViewDelegate, UIPickerViewDataSource, ConversationShareViewControllerDelegate>
@property (strong, nonatomic) UIImage *imageToProcess;
@property(strong, nonatomic) UIImage *savedImage;
@property (strong, nonatomic) IBOutlet UIImageView *theImageView;
@property (strong, nonatomic) IBOutlet UIPickerView *filterNamesPicker;
@HeidiHansen
HeidiHansen / 02. TH FilterViewController.m
Last active August 29, 2015 14:06
Image Filter View Controller
#import "FISViewController.h"
@interface FISViewController ()
@property(strong, nonatomic) CIContext *context;
@property(strong, nonatomic) CIFilter *filter;
@property(strong, nonatomic) CIImage *beginImage;
@property(strong, nonatomic) NSMutableArray *arrayOfFilters;
@property(strong, nonatomic) NSString *filtersName;
@end
@HeidiHansen
HeidiHansen / 04. THEditImageViewController.m
Last active August 29, 2015 14:06
04. THEditImageViewController.m
#import "THEditImageViewController.h"
#import "THCameraViewController.h"
#import "THEditImageViewController+Autolayout.h"
typedef void(^ButtonReplacementBlock)(void);
@interface THEditImageViewController () <UINavigationControllerDelegate, THCameraDelegateProtocol, UIScrollViewDelegate>
@property (nonatomic, assign) CGFloat zoomScale;
@property (nonatomic, assign) CGFloat maximumZoomScale;
@HeidiHansen
HeidiHansen / 05. THEditImageViewController.h
Created September 12, 2014 21:56
05. THEditImageViewController.h
#import <UIKit/UIKit.h>
#import "THCameraViewController.h"
#import "THConversationShareViewController.h"
@interface THEditImageViewController : UIViewController <ConversationShareViewControllerDelegate>
#pragma mark - Object Properties
@property (strong, nonatomic) id <ConversationShareViewControllerDelegate> delegate;