This file contains 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
// source | |
// http://stackoverflow.com/questions/9257992/how-to-combine-merge-2-images-into-1 | |
- (UIImage*)imageByCombiningImage:(UIImage*)firstImage withImage:(UIImage*)secondImage { | |
UIImage *image = nil; | |
CGSize newImageSize = CGSizeMake(MAX(firstImage.size.width, secondImage.size.width), MAX(firstImage.size.height, secondImage.size.height)); | |
if (UIGraphicsBeginImageContextWithOptions != NULL) { | |
UIGraphicsBeginImageContextWithOptions(newImageSize, NO, [[UIScreen mainScreen] scale]); | |
} else { | |
UIGraphicsBeginImageContext(newImageSize); |
This file contains 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
- (IBAction)addAlbumFoto:(id)sender { | |
// summon mr. imagepicker! | |
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; | |
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; | |
[imagePicker setDelegate:self]; | |
[self presentViewController:imagePicker animated:YES completion:nil]; |
This file contains 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
// | |
// ViewController.m | |
// erica-Sadun-textViewExample | |
// | |
// Created by Romy Ilano on 1/3/13. | |
// Copyright (c) 2013 Romy Ilano. All rights reserved. | |
// | |
#import "ViewController.h" |
This file contains 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
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) | |
{ // The iOS device = iPhone or iPod Touch | |
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size; | |
if (iOSDeviceScreenSize.height == 480) | |
{ // iPhone 3GS, 4, and 4S and iPod Touch 3rd and 4th generation: 3.5 inch screen (diagonally measured) | |
// Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone35 |
This file contains 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 *path = [[NSBundle mainBundle] pathForResource:@"kittymike_536x536" ofType:@"png"]; | |
NSURL *fileURL = [NSURL fileURLWithPath:path]; | |
CIImage *image = [CIImage imageWithContentsOfURL:fileURL]; |
This file contains 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
// Do this in the -Prefix.pch file | |
#ifdef __OBJC__ | |
#import <UIKit/UIKit.h> | |
#import <Foundation/Foundation.h> | |
// From Matt Neuberg / from Jens Alfke | |
// when you want the logs to be turned on then you set if(0) to 0 | |
// when you want them turned off you set if(1) |
This file contains 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
// define a variable that can be changed by a block | |
__block int a = 0; | |
// define a block that tries to modify a variable | |
// in its scope | |
void (^sillyBlock)(void) = ^{ a = 47 }; | |
// check the value of our variable before calling the block | |
NSLog(@"a == %d", a); // outputs " a == 0 " |
This file contains 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
char *ortData = (char *)sqlite3_column_text(statement, 3); | |
NSString *ort = ortData == NULL ? nil : [[NSString alloc] initWithUTF8String:ortData]; |
This file contains 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
// block variables - this one isn't defined | |
// block variable named adder that takes in an int parameter and an int b parameter | |
int (^adder)(int a, int b); | |
// defining block literals - here's the syntax | |
^int (int x, int y) { | |
return x + y; | |
}; |
This file contains 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
// extend NSdictionary (foundation) class | |
@interface NSDictionary(JSONCategories) | |
+(NSDictionary *)dictionaryWithContentsOfJSONURLString:(NSString *)urlAddress; | |
-(NSData *)toJSON; | |
@end | |
@implementation NSDictionary(JSONCategories) | |
+(NSDictionary *)dictionaryWithContentsOfJSONURLString:(NSString *)urlAddress | |
{ | |
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlAddress]]; |