Created
October 24, 2011 11:38
ViewController snippet from Smarty Pix
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
-(void)closeFramingView | |
{ | |
NSFileManager *fileManager= [NSFileManager defaultManager]; | |
if(![fileManager fileExistsAtPath:USER_PICS_DIRECTORY]) | |
if(![fileManager createDirectoryAtPath:USER_PICS_DIRECTORY withIntermediateDirectories:YES attributes:nil error:NULL]) | |
NSLog(@"Error: Create folder failed %@", USER_PICS_DIRECTORY); | |
NSString *pngPath = [NSString stringWithFormat:@"%@%@.png", | |
USER_PICS_DIRECTORY, [UserPrefsHandler UserPicFileName]]; | |
[UIImagePNGRepresentation([self imageFromScreenShot]) writeToFile:pngPath atomically:YES]; | |
[UserPrefsHandler setPicCount:[UserPrefsHandler PicCount]+1]; | |
[[NSNotificationCenter defaultCenter] postNotificationName:kLoadPastPics object:nil]; | |
[self.navigationController popToRootViewControllerAnimated:YES]; | |
} |
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
// | |
// NSNumber+Filenames.m | |
// SmartyPix | |
// | |
// Created by Mike Bobiney on 9/18/11. | |
// Copyright 2011 Tap Through Apps LLC. All rights reserved. | |
// | |
#import "NSNumber+Filenames.h" | |
@implementation NSNumber (NSNumber_Filenames) | |
-(NSString*)filenameStringFromNumber | |
{ | |
int len = [[self stringValue] length]; | |
int zeros = 4-len; | |
NSMutableString *template = [NSMutableString stringWithString:@""]; | |
for (int i = 0; i < zeros; i++) { | |
[template appendString:@"0"]; | |
} | |
[template appendString:[self stringValue]]; | |
return template; | |
} | |
@end |
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
// | |
// UserPrefsHandler.m | |
// SmartyPix | |
// | |
// Created by Mike Bobiney on 9/12/11. | |
// Copyright 2011 Tap Through Apps LLC. All rights reserved. | |
// | |
#import "UserPrefsHandler.h" | |
#define PIC_COUNT @"PICCOUNT" | |
@implementation UserPrefsHandler | |
+(void)setPicCount:(NSInteger)count | |
{ | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
[defaults setInteger:count forKey:PIC_COUNT]; | |
[defaults synchronize]; | |
} | |
+(NSInteger)PicCount | |
{ | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
return [defaults integerForKey:PIC_COUNT]; | |
} | |
+(NSString*)UserPicFileName | |
{ | |
NSNumber *numb = [NSNumber numberWithInteger:[self PicCount]]; | |
return [numb filenameStringFromNumber]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment