Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
runemadsen committed Apr 9, 2010
0 parents commit 30e41b7
Show file tree
Hide file tree
Showing 27 changed files with 4,020 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
*.pbxproj -crlf -diff -merge
9 changes: 9 additions & 0 deletions .gitignore
@@ -0,0 +1,9 @@
.DS_Store
*.swp
*~.nib

build/

*.pbxuser
*.perspective
*.perspectivev3
497 changes: 497 additions & 0 deletions AddTemplateViewController.xib

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions Classes/AddTemplateView.h
@@ -0,0 +1,16 @@
//
// AddTemplateView.h
// Final-Templates
//
// Created by Rune Madsen on 4/8/10.
// Copyright 2010 New York University. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface AddTemplateView : UIViewController {

}

@end
63 changes: 63 additions & 0 deletions Classes/AddTemplateView.m
@@ -0,0 +1,63 @@
//
// AddTemplateView.m
// Final-Templates
//
// Created by Rune Madsen on 4/8/10.
// Copyright 2010 New York University. All rights reserved.
//

#import "AddTemplateView.h"


@implementation AddTemplateView

/*
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
}
return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}


- (void)dealloc {
[super dealloc];
}


@end
20 changes: 20 additions & 0 deletions Classes/AddTemplateViewController.h
@@ -0,0 +1,20 @@
//
// AddTemplateViewController.h
// Final-Templates
//
// Created by Rune Madsen on 4/8/10.
// Copyright 2010 New York University. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface AddTemplateViewController : UIViewController {

IBOutlet UITextField * templateName;
IBOutlet UIButton* saveButton;
}

- (IBAction) save:(id)sender;

@end
41 changes: 41 additions & 0 deletions Classes/AddTemplateViewController.m
@@ -0,0 +1,41 @@
//
// AddTemplateViewController.m
// Final-Templates
//
// Created by Rune Madsen on 4/8/10.
// Copyright 2010 New York University. All rights reserved.
//

#import "AddTemplateViewController.h"


@implementation AddTemplateViewController

- (IBAction) save:(id)sender
{
NSNotificationCenter * dc = [NSNotificationCenter defaultCenter];
[dc postNotification:[NSNotification notificationWithName:@"SaveNewTemplate" object:self]];

[self dismissModalViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}


- (void)dealloc {
[super dealloc];
}


@end
19 changes: 19 additions & 0 deletions Classes/Final_TemplatesAppDelegate.h
@@ -0,0 +1,19 @@
//
// Final_TemplatesAppDelegate.h
// Final-Templates
//
// Created by Rune Madsen on 4/7/10.
// Copyright New York University 2010. All rights reserved.
//

@interface Final_TemplatesAppDelegate : NSObject <UIApplicationDelegate> {

UIWindow *window;
UINavigationController *navigationController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

@end

45 changes: 45 additions & 0 deletions Classes/Final_TemplatesAppDelegate.m
@@ -0,0 +1,45 @@
//
// Final_TemplatesAppDelegate.m
// Final-Templates
//
// Created by Rune Madsen on 4/7/10.
// Copyright New York University 2010. All rights reserved.
//

#import "Final_TemplatesAppDelegate.h"
#import "RootViewController.h"

@implementation Final_TemplatesAppDelegate

@synthesize window;
@synthesize navigationController;

#pragma mark -
#pragma mark Application lifecycle

- (void)applicationDidFinishLaunching:(UIApplication *)application
{
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}


- (void)applicationWillTerminate:(UIApplication *)application
{
// Save data if appropriate
}


#pragma mark -
#pragma mark Memory management

- (void)dealloc
{
[navigationController release];
[window release];
[super dealloc];
}


@end

25 changes: 25 additions & 0 deletions Classes/LCFileHelpers.h
@@ -0,0 +1,25 @@
// if you want gzip/zip suport you need to uncomment the ZLIB_SUPPORT define
// and make sure to add -lz to the Other Linker Flags in the build tab
// your project target (get info on your project target to find it)
// Thanks to Martin Ceperly.

//#define ZLIB_SUPPORT // don't uncomment this until you add the -lz linker flag to your project target

#ifdef ZLIB_SUPPORT
#import "zlib.h"
#endif

#import <Foundation/Foundation.h>

@interface LCFileHelpers : NSObject
{
}

+ (NSArray*) allDocuments;
+ (NSString*) pathToFileInDocuments:(NSString*)fileName;

#ifdef ZLIB_SUPPORT
+ (BOOL) ungzipFile: (NSString *)sourceFilenameString toDestination:(NSString *)destFilenameString;
#endif

@end
68 changes: 68 additions & 0 deletions Classes/LCFileHelpers.m
@@ -0,0 +1,68 @@
#import "LCFileHelpers.h"

#ifdef ZLIB_SUPPORT
#define CHUNK_SIZE 256000 // 256K buffer in memory
#endif

@implementation LCFileHelpers

+ (NSArray*) allDocuments
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [(NSString*)[paths objectAtIndex:0] stringByAppendingFormat:@"/"];
paths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentDirectory error:NULL];
return paths;
}

+ (NSString*) pathToFileInDocuments:(NSString*)fileName
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return [documentsDirectory stringByAppendingPathComponent:fileName];
}

#ifdef ZLIB_SUPPORT
+ (BOOL) ungzipFile: (NSString *)sourceFilenameString toDestination:(NSString *)destFilenameString
{
const char *sourceFilename = [sourceFilenameString cStringUsingEncoding:NSUTF8StringEncoding];
const char *destFilename = [destFilenameString cStringUsingEncoding:NSUTF8StringEncoding];

unsigned char out[CHUNK_SIZE];

gzFile theFile = gzopen(sourceFilename, "rb");
if(theFile == NULL) {
NSLog(@"error opening gz file");
return NO;
}

FILE *outFile = fopen(destFilename, "wb");
if(outFile == NULL) {
NSLog(@"error opening destination file");
return NO;
}

long totalBytes = 0;
int readResult = 0;

do {
readResult = gzread(theFile, out, CHUNK_SIZE);
if(readResult > 0) {
fwrite(out, 1, readResult, outFile);
totalBytes += readResult;
}
} while (readResult > 0);

gzclose(theFile);
fclose(outFile);

if(readResult == 0) {
NSLog(@"successfully uncompressed gz file, resulting file is %d bytes", totalBytes);
return YES;
} else {
NSLog(@"error reading data from gz file");
return NO;
}
}
#endif

@end
27 changes: 27 additions & 0 deletions Classes/RootViewController.h
@@ -0,0 +1,27 @@
//
// RootViewController.h
// Final-Templates
//
// Created by Rune Madsen on 4/7/10.
// Copyright New York University 2010. All rights reserved.
//

#import "TemplateViewController.h"
#import "TemplatesLoader.h"
#import "AddTemplateViewController.h"
#import "Template.h"

@interface RootViewController : UITableViewController {

TemplateViewController * templateView;
AddTemplateViewController * addTemplateView;
TemplatesLoader * loader;
}

@property (nonatomic, retain) TemplateViewController * templateView;
@property (nonatomic, retain) AddTemplateViewController * addTemplateView;
@property (nonatomic, retain) TemplatesLoader * loader;

- (void) saveNewTemplate:(id)sender;

@end

0 comments on commit 30e41b7

Please sign in to comment.