Skip to content

Instantly share code, notes, and snippets.

#define DocumentsPath(name) \
[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:name]
@zonble
zonble / iPhone 上產生一個新的 Image context
Created February 2, 2010 10:11
在 iPhone 上產生一個新的 image context 並且產生 UIImage
// 每次都忘記要這樣開頭…
UIGraphicsBeginImageContext(CGSizeMake(320.0, 320.0));
CGContextRef context = UIGraphicsGetCurrentContext();
defaultCoverImage = [UIGraphicsGetImageFromCurrentImageContext() retain];
UIGraphicsEndImageContext();
@xhan
xhan / Base64Encoding Function
Created October 13, 2009 02:58
apps in iphone send email with images
- (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength data:(NSData *)imgData {
static const char *encodingTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const unsigned char *bytes = [imgData bytes];
NSMutableString *result = [NSMutableString stringWithCapacity:[imgData length]];
unsigned long ixtext = 0;
unsigned long lentext = [imgData length];
long ctremaining = 0;
unsigned char inbuf[3], outbuf[4];
short i = 0;
@octover
octover / gist:145611
Created July 12, 2009 11:48
iPhone System Button Image Data
// save the info system button image to where you can access it, this should be able to
// go anywhere it gets run by an iPhone program, easiest if you do it with the simulator
UIButton *info = [UIButton buttonWithType:UIButtonTypeInfoLight];
NSData *img = UIImagePNGRepresentation([info imageForState:UIControlStateNormal]);
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"info.png"];
[img writeToFile:path atomically:NO];
NSLog(@"%@", path);