Clean and improve code
authorMiltiadis Vasilakis <mvasilak@gmail.com>
Tue, 20 Nov 2012 11:40:40 +0000 (13:40 +0200)
committerMiltiadis Vasilakis <mvasilak@gmail.com>
Tue, 20 Nov 2012 16:45:01 +0000 (18:45 +0200)
Remove more unnecessary code, refactor to make more readable, fix minor bugs, and improve business logic and memory use.

41 files changed:
Classes/AccountDetailsViewController.h
Classes/AccountGroupsViewController.h
Classes/AccountGroupsViewController.m
Classes/AccountHomeViewController.h
Classes/AccountHomeViewController.m
Classes/AccountManager.m
Classes/AccountSettingsViewController.h
Classes/AccountSettingsViewController.m
Classes/ActivityIndicatorView.h
Classes/ActivityIndicatorView.m
Classes/AddFileViewController.m
Classes/AddObjectViewController.m
Classes/AnimatedProgressView.h
Classes/Container.h
Classes/ContainersViewController.h
Classes/ContainersViewController.m
Classes/EditAccountGroupsViewController.h
Classes/EditAccountGroupsViewController.m
Classes/Folder.h
Classes/Folder.m
Classes/FolderViewController.h
Classes/FolderViewController.m
Classes/GetContainersRequest.m
Classes/GetObjectsRequest.m
Classes/NSObject+Conveniences.h
Classes/NSObject+NSCoding.h
Classes/NSString+Conveniences.h
Classes/NSString+Conveniences.m
Classes/OpenStackRequest.m
Classes/PithosImageViewController.h
Classes/ProvidersViewController.h
Classes/RSTextFieldCell.h
Classes/RSTextFieldCell.m
Classes/StorageObject.h
Classes/StorageObject.m
Classes/TextViewCell.h
Classes/TextViewCell.m
Classes/UIColor+MoreColors.h
Classes/UIColor+MoreColors.m
Classes/UIViewController+Conveniences.h
main.m

index 754c2d5..6ea3158 100755 (executable)
@@ -6,8 +6,6 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <UIKit/UIKit.h>
-
 @class Provider, RootViewController, OpenStackAccount, ActivityIndicatorView;
 
 @interface AccountDetailsViewController : UITableViewController <UITextFieldDelegate> {
index 4d37d99..78f8681 100644 (file)
@@ -35,9 +35,7 @@
 // interpreted as representing official policies, either expressed
 // or implied, of GRNET S.A.
 
-#import <UIKit/UIKit.h>
-#import "OpenStackAccount.h"
-#import "ActivityIndicatorView.h"
+@class OpenStackAccount, ActivityIndicatorView;
 
 @interface AccountGroupsViewController : UITableViewController {
     OpenStackAccount *account;
index 25f966f..6b603eb 100644 (file)
@@ -36,6 +36,8 @@
 // or implied, of GRNET S.A.
 
 #import "AccountGroupsViewController.h"
+#import "OpenStackAccount.h"
+#import "ActivityIndicatorView.h"
 #import "AccountManager.h"
 #import "OpenStackRequest.h"
 #import "EditAccountGroupsViewController.h"
 #import "NSString+Conveniences.h"
 #import "APICallback.h"
 
-
 @implementation AccountGroupsViewController
 
 @synthesize account, groups;
 
+#pragma mark - View lifecycle
 
-- (void)dealloc
-{
-    [account release];
-    [groups release];
-    [metadata release];
-    [activityIndicatorView release];
-    [super dealloc];
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
+    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait);
 }
 
-
-#pragma mark - View lifecycle
-
-- (void)viewDidLoad
-{
-    [super viewDidLoad];
+- (void)viewWillAppear:(BOOL)animated {
+    [super viewWillAppear:animated];
     self.navigationItem.title = @"Groups";
     groups = [[NSMutableDictionary alloc] init];
     metadata = [[NSMutableDictionary alloc] init];
     
     NSString *activityMessage = @"Loading..";
-    [activityIndicatorView release];
     activityIndicatorView = [[ActivityIndicatorView alloc] initWithFrame:[ActivityIndicatorView frameForText:activityMessage] text:activityMessage];
     [activityIndicatorView addToView:self.view];
     
-    [[self.account.manager getStorageAccountInfo] 
+    [[self.account.manager getStorageAccountInfo]
      success:^(OpenStackRequest *request) {
          [activityIndicatorView removeFromSuperview];
          for (NSString *key in request.responseHeaders) {
@@ -91,9 +83,8 @@
                  [metadata setObject:metadataValue forKey:metadataKey];
              }
          }
-
+         
          [self.tableView reloadData];
-
      }
      failure:^(OpenStackRequest *request) {
          [activityIndicatorView removeFromSuperview];
      }];
 }
 
-- (void)viewDidUnload
-{
-    [super viewDidUnload];
-    // Release any retained subviews of the main view.
-    // e.g. self.myOutlet = nil;
-}
-
-- (void)viewWillAppear:(BOOL)animated
-{
-    [super viewWillAppear:animated];
-    [self.tableView reloadData];
-}
-
-- (void)viewDidAppear:(BOOL)animated
-{
-    [super viewDidAppear:animated];
-}
-
-- (void)viewWillDisappear:(BOOL)animated
-{
-    [super viewWillDisappear:animated];
-}
-
-- (void)viewDidDisappear:(BOOL)animated
-{
-    [super viewDidDisappear:animated];
-}
+#pragma mark - Memory management
 
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
-    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait);
+- (void)dealloc {
+    [account release];
+    [groups release];
+    [metadata release];
+    [activityIndicatorView release];
+    [super dealloc];
 }
 
-#pragma mark - Table view data source
-
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
-{
-    return 1;
-}
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
-{
-    return [groups count] + 1;
-}
+#pragma mark - Internal
 
 - (CGFloat)findLabelHeight:(NSString*)text font:(UIFont *)font {
-    CGSize textLabelSize;    
+    CGSize textLabelSize;
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
         // 616, 678
         textLabelSize = CGSizeMake(596.0, 9000.0f);
     return stringSize.height;
 }
 
+#pragma mark - UITableViewDataSource
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    return [groups count] + 1;
+}
+
 - (CGFloat)tableView:(UITableView *)aTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
     CGFloat result;
     
 }
 
 
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
-{
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     static NSString *CellIdentifier = @"Cell";
     
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
         cell.detailTextLabel.text = [groups objectForKey:groupName];
         cell.detailTextLabel.numberOfLines = 0;
         cell.detailTextLabel.lineBreakMode = UILineBreakModeCharacterWrap;
-    }
-    else {
+    } else {
         cell.textLabel.text = @"Add Group";
         cell.detailTextLabel.text = @"";
     }
 }
 
 
-#pragma mark - Table view delegate
+#pragma mark - UITableViewDelegate
 
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
-{
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     EditAccountGroupsViewController *vc = [[EditAccountGroupsViewController alloc] initWithNibName:@"EditAccountGroupsViewController" bundle:nil];
-    
     vc.account = self.account;
     vc.metadata = metadata;
     vc.groups = groups;
-    if (indexPath.row < [groups count]) {        
+    if (indexPath.row < [groups count]) {
         NSString *groupName = [[groups allKeys] objectAtIndex:indexPath.row];
         NSString *groupUsers = [groups objectForKey:groupName];
         
         vc.groupName = groupName;
         vc.groupUsers = groupUsers;
         vc.navigationItem.title = @"Edit Group";
-    }
-    else {
+    } else {
         vc.removeGroupEnabled = NO;
         vc.groupName = @"";
         vc.groupUsers = @"";
     [vc release];
 }
 
-
 @end
index 2faafdc..c3c9824 100755 (executable)
@@ -13,7 +13,6 @@
 @interface AccountHomeViewController : OpenStackViewController <UITableViewDelegate, UITableViewDataSource> {
     OpenStackAccount *account;
     RootViewController *rootViewController;
-    NSArray *observers;
     IBOutlet UITableView *tableView;
     
     NSInteger refreshCount;
index 028146f..4507552 100755 (executable)
     othersSharedRow = 1;
     accountSettingsRow = 0;
     accountMetadataRow = 1;
-    
-    id getContainersObserver = [[NSNotificationCenter defaultCenter]
-                                addObserverForName:@"getContainersSucceeded"
-                                object:self.account
-                                queue:[NSOperationQueue mainQueue]
-                                usingBlock:^(NSNotification *notification) {
-                                    [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:storageRow inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
-                                    [self incrementRefreshCount];
-                                }];
-    id getContainersFailedObserver = [[NSNotificationCenter defaultCenter]
-                                      addObserverForName:@"getContainersFailed"
-                                      object:self.account
-                                      queue:[NSOperationQueue mainQueue]
-                                      usingBlock:^(NSNotification *notification) {
-                                          [self incrementRefreshCount];
-                                      }];
-    id createContainerObserver = [[NSNotificationCenter defaultCenter]
-                                  addObserverForName:@"createContainerSucceeded"
-                                  object:self.account
-                                  queue:[NSOperationQueue mainQueue]
-                                  usingBlock:^(NSNotification *notification) {
-                                      [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:storageRow inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
-                                  }];
-    id deleteContainerObserver = [[NSNotificationCenter defaultCenter]
-                                  addObserverForName:@"deleteContainerSucceeded"
-                                  object:self.account
-                                  queue:[NSOperationQueue mainQueue]
-                                  usingBlock:^(NSNotification *notification) {
-                                      [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:storageRow inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
-                                  }];
-    
-    observers = [[NSArray alloc] initWithObjects: getContainersObserver, getContainersFailedObserver, createContainerObserver, deleteContainerObserver, nil];
 }
 
 - (void)viewWillAppear:(BOOL)animated {
     }
 }
 
-- (void)viewDidUnload {
-    for (id observer in observers) {
-        [[NSNotificationCenter defaultCenter] removeObserver:observer];
-    }
-    
-    [super viewDidUnload];
-}
-
 #pragma mark - Memory management
 
 - (void)dealloc {
     [account release];
     [rootViewController release];
-    [observers release];
     [tableView release];
     [super dealloc];
 }
 
-#pragma mark - Internal
-
-- (void)incrementRefreshCount {
-    refreshCount++;
-    self.account.hasBeenRefreshed = YES;
-    [self hideToolbarActivityMessage];
-}
-
 #pragma mark - UITableViewDataSource
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
             cell.textLabel.text = @"Account Token";
             cell.imageView.image = [UIImage imageNamed:@"account-settings-icon.png"];
         } else if (indexPath.row == accountMetadataRow) {
-            cell.textLabel.text = @"Account Metadata";
+            cell.textLabel.text = @"Account Groups";
             cell.imageView.image = [UIImage imageNamed:@"account-settings-icon.png"];
         }
         if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
             vc.account = account;
             vc.accountHomeViewController = self;
             [self.navigationController pushViewController:vc animated:YES];
-            [vc refreshButtonPressed:nil];
             [vc release];
         }
     } else if (indexPath.section == kShared) {
             vc.account = account;
             vc.accountHomeViewController = self;
             [self.navigationController pushViewController:vc animated:YES];
-            [vc refreshButtonPressed:nil];
-            [vc release];    
+            [vc release];
         } else if (indexPath.row == othersSharedRow){
             SharingAccountsViewController *vc = [[SharingAccountsViewController alloc] initWithNibName:@"SharingAccountsViewController" bundle:nil];
             vc.account = account;
index 4794c7f..fae5e72 100755 (executable)
 
 - (void)requestFinished:(OpenStackRequest *)request {
     NSString *notificationName = [request.userInfo objectForKey:@"notificationName"];
-    id notificationObject = [request.userInfo objectForKey:@"notificationObject"];
+    if (!notificationName)
+        return;
     
+    id notificationObject = [request.userInfo objectForKey:@"notificationObject"];
     if ([request isSuccess]) {
         NSNotification *notification = [NSNotification notificationWithName:[NSString stringWithFormat:@"%@Succeeded", notificationName] object:notificationObject];
         [[NSNotificationCenter defaultCenter] postNotification:notification];
 
 - (void)requestFailed:(OpenStackRequest *)request {
     NSString *notificationName = [request.userInfo objectForKey:@"notificationName"];
+    if (!notificationName)
+        return;
+    
     id notificationObject = [request.userInfo objectForKey:@"notificationObject"];
     NSNotification *notification = [NSNotification notificationWithName:[NSString stringWithFormat:@"%@Failed", notificationName] object:notificationObject userInfo:[NSDictionary dictionaryWithObject:request forKey:@"request"]];
     [[NSNotificationCenter defaultCenter] postNotification:notification];
 }
 
-- (void)sendRequest:(OpenStackRequest *)request name:(NSString *)name object:(id)notificationObject {
-    request.delegate = self;
-    request.userInfo = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:name, notificationObject, nil] forKeys:[NSArray arrayWithObjects:@"notificationName", @"notificationObject", nil]];
-    [request startAsynchronous];
-}
-
 - (void)notify:(NSString *)name request:(OpenStackRequest *)request {
     NSNotification *notification = [NSNotification notificationWithName:name object:nil userInfo:[NSDictionary dictionaryWithObject:request forKey:@"request"]];
     [[NSNotificationCenter defaultCenter] postNotification:notification];
index 7c76a58..85fba34 100755 (executable)
@@ -6,10 +6,7 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <UIKit/UIKit.h>
-#import "ActivityIndicatorView.h"
-
-@class OpenStackAccount;
+@class OpenStackAccount, ActivityIndicatorView;
 
 @interface AccountSettingsViewController : UITableViewController <UITextFieldDelegate> {
     UITextField *usernameTextField;
index 2bc12c6..e5bfd0a 100755 (executable)
@@ -8,6 +8,7 @@
 
 #import "AccountSettingsViewController.h"
 #import "OpenStackAccount.h"
+#import "ActivityIndicatorView.h"
 #import "Provider.h"
 #import "RSTextFieldCell.h"
 #import "UIColor+MoreColors.h"
index 59ef71c..a9ac9f9 100755 (executable)
@@ -6,8 +6,6 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <UIKit/UIKit.h>
-
 #define kFadeTime 0.25
 #define kFontSize 14.0
 #define kCornerRadius 7
index c9f9a04..4b3eb21 100755 (executable)
@@ -10,7 +10,6 @@
 #import <QuartzCore/QuartzCore.h>
 #import "AnimatedProgressView.h"
 
-
 @implementation ActivityIndicatorView
 
 @synthesize progressView, spinner;
index e998294..678ff2c 100755 (executable)
@@ -21,7 +21,7 @@
 #import "AddPhotoViewController.h"
 #import "UploadGenericFileViewController.h"
 #import "AddTextFileViewController.h"
-
+#import <MobileCoreServices/MobileCoreServices.h>
 
 @implementation AddFileViewController
 
     popover = nil;
 }
 
-
-/*
-- (void)viewWillAppear:(BOOL)animated {
-    [super viewWillAppear:animated];
-}
-*/
-/*
-- (void)viewDidAppear:(BOOL)animated {
-    [super viewDidAppear:animated];
-}
-*/
-/*
-- (void)viewWillDisappear:(BOOL)animated {
-    [super viewWillDisappear:animated];
-}
-*/
-/*
-- (void)viewDidDisappear:(BOOL)animated {
-    [super viewDidDisappear:animated];
-}
-*/
-/*
-// Override to allow orientations other than the default portrait orientation.
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
-    // Return YES for supported orientations.
-    return (interfaceOrientation == UIInterfaceOrientationPortrait);
-}
-*/
-
-
 #pragma mark -
 #pragma mark Table view data source
 
     } else if (indexPath.section == textFileSection) {
         cell.textLabel.text = @"Text File";
 
+//        NSString *emptyPath = [[NSBundle mainBundle] pathForResource:@"empty-file" ofType:@""];
+//        UIDocumentInteractionController *udic = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:emptyPath]];
+//        cell.imageView.image = [udic.icons objectAtIndex:0]; //[UIImage imageNamed:@"file-icon.png"];        
+        CFStringRef mimeType = (CFStringRef)@"text/plain";
+        CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType, NULL);
         NSString *emptyPath = [[NSBundle mainBundle] pathForResource:@"empty-file" ofType:@""];
         UIDocumentInteractionController *udic = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:emptyPath]];
-        cell.imageView.image = [udic.icons objectAtIndex:0]; //[UIImage imageNamed:@"file-icon.png"];        
+        if (((NSString *)uti).length > 0)
+            udic.UTI = (NSString *)uti;
+        if ([udic.icons count] > 0)
+            cell.imageView.image = [udic.icons objectAtIndex:0];
     } else if (indexPath.section == audioSection) {
         cell.textLabel.text = @"Record Audio";
         cell.imageView.image = [UIImage imageNamed:@"audio-icon.png"];
index fa4fe27..c816feb 100755 (executable)
@@ -10,6 +10,7 @@
 #import "UIViewController+Conveniences.h"
 #import "AddFolderViewController.h"
 #import "AddFileViewController.h"
+#import <MobileCoreServices/MobileCoreServices.h>
 
 #define kFolder 0
 #define kFile 1
         cell.imageView.image = [UIImage imageNamed:@"folder-icon.png"];
     } else if (indexPath.section == kFile) {
         cell.textLabel.text = @"Add a File";
+//        NSString *emptyPath = [[NSBundle mainBundle] pathForResource:@"empty-file" ofType:@""];
+//        UIDocumentInteractionController *udic = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:emptyPath]];
+//        cell.imageView.image = [udic.icons objectAtIndex:0]; //[UIImage imageNamed:@"file-icon.png"];
+        CFStringRef mimeType = (CFStringRef)@"text/plain";
+        CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType, NULL);
         NSString *emptyPath = [[NSBundle mainBundle] pathForResource:@"empty-file" ofType:@""];
         UIDocumentInteractionController *udic = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:emptyPath]];
-        cell.imageView.image = [udic.icons objectAtIndex:0]; //[UIImage imageNamed:@"file-icon.png"];        
+        if (((NSString *)uti).length > 0)
+            udic.UTI = (NSString *)uti;
+        if ([udic.icons count] > 0)
+            cell.imageView.image = [udic.icons objectAtIndex:0];
     }
     
     return cell;
index a1061b3..018d1e8 100755 (executable)
@@ -6,10 +6,8 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <Foundation/Foundation.h>
 #import "ASIProgressDelegate.h"
 
-
 @interface AnimatedProgressView : UIProgressView {
     NSTimer *progressTimer;
     CGFloat targetProgress;
index c1c7553..b6166b2 100755 (executable)
@@ -6,8 +6,6 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <Foundation/Foundation.h>
-
 @class Folder;
 
 @interface Container : NSObject <NSCoding>  {
 @property (nonatomic, assign) NSUInteger count;
 @property (nonatomic, assign) unsigned long long bytes;
 
-//metadata
-@property (nonatomic, retain) NSMutableDictionary *metadata;
-
 //policy
 @property (nonatomic, retain) NSString *versioning;
 @property (nonatomic) NSUInteger quota;
 
--(NSString *)humanizedSize;
+//metadata
+@property (nonatomic, retain) NSMutableDictionary *metadata;
+
+- (NSString *)humanizedSize;
 - (NSString *)osxStyleHumanizedSize;
 
 // CDN container attributes
index 8cf19f2..f389ffe 100755 (executable)
@@ -8,9 +8,7 @@
 
 #import "OpenStackViewController.h"
 
-@class OpenStackAccount;
-@class AccountHomeViewController;
-@class ContainerDetailViewController;
+@class OpenStackAccount, AccountHomeViewController, ContainerDetailViewController;
 
 @interface ContainersViewController : OpenStackViewController <UITableViewDelegate, UITableViewDataSource> {
     IBOutlet UITableView *tableView;
         
     IBOutlet UIBarButtonItem *refreshButton;
     
-    id getContainersSucceededObserver;
-    id getContainersFailedObserver;
-    
     BOOL containersLoaded;
     NSString *accountUsageInfo;
     AccountHomeViewController *accountHomeViewController;
     ContainerDetailViewController *containerDetailViewController;
-    
 }
 
 @property (nonatomic, retain) IBOutlet UITableView *tableView;
@@ -35,7 +29,5 @@
 @property (nonatomic, retain) ContainerDetailViewController *containerDetailViewController;
 
 - (void)refreshButtonPressed:(id)sender;
-- (NSString *)humanReadableSize:(unsigned long long)bytes;
-- (void)createContainerWithName:(NSString *)containerName;
 
 @end
index 9d25113..980cb64 100755 (executable)
 #import "Provider.h"
 #import "AccountHomeViewController.h"
 
-
 @implementation ContainersViewController
 
 @synthesize tableView, account, accountUsageInfo, accountHomeViewController, containerDetailViewController;
 
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
-    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait);
-}
-
-#pragma mark -
-#pragma mark View lifecycle
+#pragma mark - View lifecycle
 
 - (void)viewDidLoad {
     [super viewDidLoad];
     self.navigationItem.title = @"Containers";
     [self addAddButton]; 
     [self addHomeButton];
-    
-    if (!account.shared && !account.sharingAccount && containersLoaded) {
-        if (![self.account.containers objectForKey:@"pithos"])
-            [self createContainerWithName:@"pithos"];
-        if (![self.account.containers objectForKey:@"trash"])
-            [self createContainerWithName:@"trash"];
-    }
-
 }
 
 - (void)viewWillAppear:(BOOL)animated {
         }
     }
     
-    if (!containersLoaded && [self.account.containers count] == 0) {
-        [self refreshButtonPressed:nil];
-    }
+    [self refreshButtonPressed:nil];
+}
+
+#pragma mark - Memory management
+
+- (void)dealloc {
+    [accountUsageInfo release];
+    [tableView release];
+    [account release];
+    [containerDetailViewController release];
+    [super dealloc];
+}
+
+#pragma mark - Internal
+
+- (void)enableRefreshButton {
+    refreshButton.enabled = YES;
+    [self hideToolbarActivityMessage];
+    if (!account.sharingAccount)
+        [self showToolbarInfoMessage:accountUsageInfo];
 }
 
-- (void)viewDidDisappear:(BOOL)animated {
-    [super viewDidDisappear:animated];
+- (void)createContainerWithName:(NSString *)containerName {
+    [self hideToolbarInfoMessage];
+    [self showToolbarActivityMessage:@"Creating container..."];
+    Container *container = [[Container alloc] init];
+    container.name = containerName;
+    [[self.account.manager createContainer:container]
+     success:^(OpenStackRequest *request) {
+         [self hideToolbarActivityMessage];
+         if (!account.sharingAccount)
+             [self showToolbarInfoMessage:accountUsageInfo];
+         [self.tableView reloadData];
+     }
+     failure:^(OpenStackRequest *request) {
+         [self hideToolbarActivityMessage];
+         if (!account.sharingAccount)
+             [self showToolbarInfoMessage:accountUsageInfo];
+         [self alert:@"There was a problem creating your container." request:request];
+     }];
+    [container release];
 }
 
-#pragma mark -
-#pragma mark Button Handlers
+#pragma mark - Button Handlers
 
 - (void)addButtonPressed:(id)sender {
     AddContainerViewController *vc = [[AddContainerViewController alloc] initWithNibName:@"AddContainerViewController" bundle:nil];
     vc.containersViewController = self;
     vc.account = account;
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
-        vc.modalPresentationStyle = UIModalPresentationFormSheet;
         OpenStackAppDelegate *app = [[UIApplication sharedApplication] delegate];
-        if (app.rootViewController.popoverController != nil) {
-            [app.rootViewController.popoverController dismissPopoverAnimated:YES];
-        }
-    }                
+        [app.rootViewController.popoverController dismissPopoverAnimated:YES];
+    }
     [self presentModalViewControllerWithNavigation:vc];
     [vc release];
 }
     [self.navigationController popToViewController:accountHomeViewController animated:YES];
 }
 
-
-- (void)enableRefreshButton {
-    refreshButton.enabled = YES;
-    [self hideToolbarActivityMessage];
-    if (!account.sharingAccount)
-        [self showToolbarInfoMessage:accountUsageInfo];
-}
-
 - (void)refreshButtonPressed:(id)sender {
     refreshButton.enabled = NO;
-        //BOOL hadZeroContainers = [self.account.containers count] == 0;
     if (!account.sharingAccount)
         [self hideToolbarInfoMessage];
     [self showToolbarActivityMessage:@"Refreshing containers..."];
         containersLoaded = YES;
         [self enableRefreshButton];
         [self.tableView reloadData];
-        //GetCDNContainersRequest *cdnRequest = [GetCDNContainersRequest request:self.account];
-        //[cdnRequest startAsynchronous];
-        
+        if (!account.shared && !account.sharingAccount) {
+            if (![self.account.containers objectForKey:@"pithos"])
+                [self createContainerWithName:@"pithos"];
+            if (![self.account.containers objectForKey:@"trash"])
+                [self createContainerWithName:@"trash"];
+        }
     } failure:^(OpenStackRequest *request) {
         containersLoaded = NO;
         [self enableRefreshButton];
     }];
 }
 
-#pragma mark -
-#pragma mark Table view data source
-
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
-    return 1;
-}
+#pragma mark - UITableViewDataSource
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
     if ([self.account.containers count] == 0) {
         return aTableView.rowHeight;
     }
 }
+
 - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     if (containersLoaded && [self.account.containers count] == 0) {
         NSString *noContainersTitle = self.account.shared ? @"No shared containers" : @"No containers";
     }
 }
 
-#pragma mark -
-#pragma mark Table view delegate
+#pragma mark - UITableViewDelegate
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     Container *container = nil;
     [vc release];
 }
 
-#pragma mark -
-#pragma mark Helper methods
-
-- (NSString *)humanReadableSize:(unsigned long long)bytes {
-    NSString *sizeUnit = @"bytes";
-        
-    double sizeInBytes = bytes; 
-    if (bytes > 1023 && bytes < 1048576) {
-        sizeInBytes =  bytes / 1024.0;
-        sizeUnit = @"Kb";
-    }
-    else if (bytes > 1048575 && bytes < 1073741824) {
-        sizeInBytes = bytes / 1048576.0;
-        sizeUnit = @"Mb";
-    }
-    else if (bytes > 1073741823) {
-        sizeInBytes = bytes / 1073741824.0;
-        sizeUnit = @"Gb";
-    }
-        
-    NSString *humanReadableString = [NSString stringWithFormat:@"%.1f %@", sizeInBytes, sizeUnit];
-    humanReadableString = [humanReadableString stringByReplacingOccurrencesOfString:@".0" withString:@""];
-    
-    return humanReadableString;
-}
-
-- (void)createContainerWithName:(NSString *)containerName {
-    [self hideToolbarInfoMessage];
-    [self showToolbarActivityMessage:@"Creating container..."];
-    Container *container = [[Container alloc] init];
-    container.name = containerName;
-    [[self.account.manager createContainer:container]
-     success:^(OpenStackRequest *request) {
-         [self hideToolbarActivityMessage];
-         if (!account.sharingAccount)
-             [self showToolbarInfoMessage:accountUsageInfo];
-         [self.tableView reloadData];
-     }
-     failure:^(OpenStackRequest *request) {
-         [self hideToolbarActivityMessage];
-         if (!account.sharingAccount)
-             [self showToolbarInfoMessage:accountUsageInfo];
-         [self alert:@"There was a problem creating your container." request:request];
-     }];
-    [container release];
-}
-
-
-#pragma mark -
-#pragma mark Memory management
-
-- (void)dealloc {
-    [accountUsageInfo release];
-    [tableView release];
-    [account release];
-    [containerDetailViewController release];
-    [super dealloc];
-}
-
 @end
index 5188114..9c0b596 100644 (file)
 // interpreted as representing official policies, either expressed
 // or implied, of GRNET S.A.
 
-#import <UIKit/UIKit.h>
-#import "OpenStackAccount.h"
-#import "ActivityIndicatorView.h"
-
-
+@class OpenStackAccount, ActivityIndicatorView;
 
 @interface EditAccountGroupsViewController : UITableViewController <UITextFieldDelegate> {
     OpenStackAccount *account;
@@ -60,6 +56,4 @@
 @property (nonatomic, retain) NSMutableDictionary *metadata;
 @property (nonatomic) BOOL removeGroupEnabled;
 
-- (BOOL)userInputIsValid:(NSString *)input fieldName:(NSString *)fieldName;
-
 @end
index d0bf4aa..ef782c5 100644 (file)
@@ -36,6 +36,8 @@
 // or implied, of GRNET S.A.
 
 #import "EditAccountGroupsViewController.h"
+#import "OpenStackAccount.h"
+#import "ActivityIndicatorView.h"
 #import "UIViewController+Conveniences.h"
 #import "AccountManager.h"
 #import "OpenStackRequest.h"
 @synthesize groupName, groupUsers, removeGroupEnabled;
 @synthesize groups,metadata;
 
+#pragma mark - View lifecycle
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
+    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait);
+}
+
+#pragma mark - Memory management
 
-- (void)dealloc
-{
+- (void)dealloc {
     [groupName release];
     [groupUsers release];
     [account release];
     [super dealloc];
 }
 
+#pragma mark - Internal
 
-#pragma mark - View lifecycle
-
-- (void)viewDidLoad
-{
-    [super viewDidLoad];
-}
-
-- (void)viewDidUnload
-{
-    [super viewDidUnload];
-}
-
-- (void)viewWillAppear:(BOOL)animated
-{
-    [super viewWillAppear:animated];
-}
-
-- (void)viewDidAppear:(BOOL)animated
-{
-    [super viewDidAppear:animated];
-}
-
-- (void)viewWillDisappear:(BOOL)animated
-{
-    [super viewWillDisappear:animated];
-}
-
-- (void)viewDidDisappear:(BOOL)animated
-{
-    [super viewDidDisappear:animated];
-}
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
-    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait);
+- (BOOL)userInputIsValid:(NSString *)input fieldName:(NSString *)fieldName {
+    if (![input length] || ![[input stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length]) {
+        [self alert:@"Invalid input" message:[NSString stringWithFormat:@"%@ field cannot be empty", fieldName]];
+        return NO;
+    }
+    NSCharacterSet *set = [NSCharacterSet characterSetWithCharactersInString:@"= "];
+    if ([input rangeOfCharacterFromSet:set].location != NSNotFound) {
+        [self alert:@"Invalid input" message:[NSString stringWithFormat:@"%@ field cannot contain '=' or whitespace characters", fieldName]];
+        return NO;
+    }
+    return YES;
 }
 
-#pragma mark - Table view data source
+#pragma mark - UITableViewDataSource
 
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
-{
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
     if (removeGroupEnabled)
         return 3;
     else
         return 2;
 }
 
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
-{
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
     if (section == kGroupDetails)
         return 2;
     else
         return 1;
 }
 
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
-{
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     static NSString *CellIdentifier = @"Cell";
     
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
             textField.placeholder = @"Group name";
             textField.text = self.groupName;
             textField.tag = 0;
-        }
-        else if (indexPath.row == 1) {
+        } else if (indexPath.row == 1) {
             textField.returnKeyType = UIReturnKeyDefault;
             textField.placeholder = @"Group users";
             textField.text = self.groupUsers;
         }
         cell.selectionStyle = UITableViewCellSelectionStyleNone;
         [cell.contentView addSubview:textField];
-    }
-    else if (indexPath.section == kSave) { 
+    } else if (indexPath.section == kSave) {
         cell.textLabel.text = @"Save";
-    }
-    else if (indexPath.section == kRemove) {
+    } else if (indexPath.section == kRemove) {
         cell.textLabel.text = @"Remove";
     }
     
-    
     return cell;
 }
 
-#pragma mark - Table view delegate
+#pragma mark - UITableViewDelegate
 
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
-{
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     NSString *activityMessage;
     NSIndexPath *keyCellIndexPath;
     NSIndexPath *valueCellIndexPath;
     }
 }
 
-#pragma mark - Textfield delegate
+#pragma mark - UITextFieldDelegate
 
-- (BOOL)textFieldShouldReturn:(UITextField *)textField
-{
-    
-    if ([textField returnKeyType] == UIReturnKeyNext)
-    {
+- (BOOL)textFieldShouldReturn:(UITextField *)textField {
+    if ([textField returnKeyType] == UIReturnKeyNext) {
         [self userInputIsValid:textField.text fieldName:@"Group name"];
 
         NSInteger nextTag = [textField tag] + 1;
         UIView *nextTextField = [self.tableView viewWithTag:nextTag];
         [nextTextField becomeFirstResponder];
-    }
-    else
-    {
+    } else {
         [self userInputIsValid:textField.text fieldName:@"Group users"];
         [textField resignFirstResponder];
     }
     return YES;
 }
 
-#pragma mark - Helper methods
-
-- (BOOL)userInputIsValid:(NSString *)input fieldName:(NSString *)fieldName {
-    if (![input length] || ![[input stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length]) {
-        [self alert:@"Invalid input" message:[NSString stringWithFormat:@"%@ field cannot be empty", fieldName]];
-        return NO;
-    }
-    NSCharacterSet *set = [NSCharacterSet characterSetWithCharactersInString:@"= "];
-    if ([input rangeOfCharacterFromSet:set].location != NSNotFound) {
-        [self alert:@"Invalid input" message:[NSString stringWithFormat:@"%@ field cannot contain '=' or whitespace characters", fieldName]];
-        return NO;
-    }
-    
-    return YES;
-}
-
-
-
 @end
index 5bc62d8..7763ea9 100755 (executable)
@@ -6,8 +6,6 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <Foundation/Foundation.h>
-
 // there isn't really a folder resource in the API.  this is an
 // abstraction to simulate folders based on object names with
 // slashes in them.
@@ -20,8 +18,8 @@
 @interface Folder : NSObject <NSCoding> {
        NSString *name;
        Folder *parent;
-       NSMutableDictionary *folders;
        NSMutableDictionary *objects;
+       NSMutableDictionary *folders;
     NSArray *sortedContents;
     
     NSString *sharing;
@@ -31,8 +29,8 @@
 
 @property (nonatomic, retain) NSString *name;
 @property (nonatomic, retain) Folder *parent;
-@property (nonatomic, retain) NSMutableDictionary *folders;
 @property (nonatomic, retain) NSMutableDictionary *objects;
+@property (nonatomic, retain) NSMutableDictionary *folders;
 @property (readonly, retain) NSArray *sortedContents;
 @property (nonatomic, retain) NSString *sharing;
 @property (nonatomic, retain) NSMutableDictionary *metadata;
index 0a120ad..cb9daac 100755 (executable)
 #import "NSObject+NSCoding.h"
 #import "PithosUtilities.h"
 
-
 @implementation Folder
 
-@synthesize name, parent, folders, objects, metadata, sharing, contentType;
-
-+ (id)folder {
-       Folder *folder = [[[self alloc] init] autorelease];
-       folder.folders = [[[NSMutableDictionary alloc] init] autorelease];
-       folder.objects = [[[NSMutableDictionary alloc] init] autorelease];
-       return folder;
-}
+@synthesize name, parent, objects, folders, sharing, metadata, contentType;
 
-#pragma mark -
-#pragma mark Serialization
+#pragma mark - Object lifecycle
 
 - (id)init {
-    if (self = [super init]) {
-        self.folders = [[[NSMutableDictionary alloc] init] autorelease];
-        self.objects = [[[NSMutableDictionary alloc] init] autorelease];
+    if ((self = [super init])) {
+        objects = [[NSMutableDictionary alloc] init];
+        folders = [[NSMutableDictionary alloc] init];
     }
     return self;
 }
 
-- (void)encodeWithCoder:(NSCoder *)coder {
-    [self autoEncodeWithCoder:coder];
-    /*
-    [coder encodeObject:name forKey:@"name"];
-    [coder encodeObject:parent forKey:@"parent"];
-    [coder encodeObject:folders forKey:@"folders"];
-    [coder encodeObject:objects forKey:@"objects"];
-     */
++ (id)folder {
+    return [[[self alloc] init] autorelease];
+}
+
+- (NSComparisonResult)compare:(Folder *)aFolder {
+    return [self.name caseInsensitiveCompare:aFolder.name];
 }
 
+#pragma mark - Serialization
+
 - (id)initWithCoder:(NSCoder *)coder {
-    if (self = [super init]) {
+    if ((self = [super init])) {
         [self autoDecode:coder];
-        /*
-        name = [[coder decodeObjectForKey:@"name"] retain];
-        parent = [[coder decodeObjectForKey:@"parent"] retain];
-        folders = [[coder decodeObjectForKey:@"folders"] retain];
-        objects = [[coder decodeObjectForKey:@"objects"] retain];
-         */
     }
     return self;
 }
 
+- (void)encodeWithCoder:(NSCoder *)coder {
+    [self autoEncodeWithCoder:coder];
+}
+
+#pragma mark - Memory management
+
+-(void)dealloc {
+       [name release];
+       [parent release];
+       [folders release];
+    [sharing release];
+       [objects release];
+    [sortedContents release];
+    [contentType release];
+       [super dealloc];
+}
+
+#pragma mark - Properties
 
 - (void)setObjects:(NSMutableDictionary *)objs {
-    if (self.objects != objs) {
+    if (![objects isEqualToDictionary:objs]) {
         [objects release];
-        NSMutableDictionary *folderedFiles = [[NSMutableDictionary alloc] init];
-        NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
-        folders = [[NSMutableDictionary alloc] init];
+        NSMutableDictionary *folderedFiles = [NSMutableDictionary dictionary];
+        NSMutableDictionary *files = [NSMutableDictionary dictionary];
+        self.folders = [[NSMutableDictionary alloc] init];
 
         for (NSString *key in objs) {
             StorageObject *object = [objs objectForKey:key];
                 object.name = [object.name substringToIndex:(object.name.length - 1)];
             }
 
-            NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"/" options:NSRegularExpressionCaseInsensitive error:nil];            
-            NSInteger matches = [regex numberOfMatchesInString:object.name options:0 range:NSMakeRange(0, [object.name length])];
-
-            if (matches > 0) {
+            NSRange slashRange = [object.name rangeOfString:@"/"];
+            if (slashRange.location != NSNotFound) {
                 // build up the folder structure
-                NSMutableArray *components = [NSMutableArray arrayWithArray:[object.name componentsSeparatedByString:@"/"]];
-                NSString *folderName = [components objectAtIndex:0];
-                
-                object.name = [components lastObject];
+                NSString *folderName = [object.name substringToIndex:slashRange.location];
+                object.name = [object.name substringFromIndex:(slashRange.location + 1)];
                 if (objectHasTrailingSlash)
                     object.name = [object.name stringByAppendingString:@"/"];
                 
-                for (int i = [components count] - 2; i > 0; i--) {
-                    object.name = [NSString stringWithFormat:@"%@/%@", [components objectAtIndex:i], object.name];
-                }
-                
                 if (![folderedFiles objectForKey:folderName]) {
                     [folderedFiles setObject:[NSMutableDictionary dictionary] forKey:folderName];
                 }
@@ -96,9 +91,9 @@
                 NSMutableDictionary *folderFiles = [folderedFiles objectForKey:folderName];
                 [folderFiles setObject:object forKey:object.name]; 
             } else if ([PithosUtilities isContentTypeDirectory:object.contentType]) {
-                Folder *folder = [[Folder alloc] init];
+                Folder *folder = [Folder folder];
                 if (objectHasTrailingSlash)
-                    folder.name = [NSString stringWithFormat:@"%@/", object.name];
+                    folder.name = [object.name stringByAppendingString:@"/"];
                 else
                     folder.name = object.name;
                 folder.parent = self;
                 folder.sharing = object.sharing;
                 folder.contentType = object.contentType;
                 [self.folders setObject:folder forKey:folder.name];
-                [folder release];
             } else {
                 // put the files in this folder 
                 if (objectHasTrailingSlash)
         }
         
         // take the foldered files and recursively build the rest of the folder structure
-        NSArray *keys = [folderedFiles allKeys];
-        for (int i = 0; i < [keys count]; i++) {
-            NSString *folderName = [keys objectAtIndex:i];
+        for (NSString *folderName in [folderedFiles allKeys]) {
             NSMutableDictionary *folderFiles = [folderedFiles objectForKey:folderName];
-            Folder *folder = [[Folder alloc] init];
+            Folder *folder = [Folder folder];
             folder.name = folderName;
             folder.parent = self;
             folder.objects = folderFiles;
             StorageObject *object = [objs objectForKey:folderName];
-            if ([PithosUtilities isContentTypeDirectory:object.contentType]) {
+            if (object && [PithosUtilities isContentTypeDirectory:object.contentType]) {
                 folder.metadata = object.metadata;
                 folder.sharing = object.sharing;
                 folder.contentType = object.contentType;
                 folder.metadata = [NSMutableDictionary dictionary];
             }
             [self.folders setObject:folder forKey:folder.name];
-            [folder release];
         }
         
-        [folderedFiles release];
-        objects = files;
+        objects = [files retain];
+        [sortedContents release];
+        sortedContents = nil;
     }
 }
 
 - (NSArray *)sortedContents {
-    NSMutableArray *contents = [[NSMutableArray alloc] initWithArray:[self.folders allValues]];
-    
-    [contents addObjectsFromArray:[self.objects allValues]];
-    if (!sortedContents || ![sortedContents isEqualToArray:contents]) {
+    if (!sortedContents) {
+        NSMutableArray *contents = [[NSMutableArray alloc] initWithArray:[self.folders allValues]];
+        [contents addObjectsFromArray:[self.objects allValues]];
         sortedContents = [[NSArray alloc] initWithArray:[contents sortedArrayUsingSelector:@selector(compare:)]];
     }
-    [contents release];
     return sortedContents;
 }
 
-- (NSComparisonResult)compare:(Folder *)aFolder {
-    return [self.name caseInsensitiveCompare:aFolder.name];
-}
+#pragma mark - Actions
 
 - (NSString *)fullPath {
-    NSString *result = self.name;
-    if (parent) {
-        result = [NSString stringWithFormat:@"%@/%@", [parent fullPath], self.name];
+    if (self.parent) {
+        return [[self.parent fullPath] stringByAppendingFormat:@"/%@", self.name];
+    } else if (self.name) {
+        return self.name;
+    } else {
+        return @"";
     }
-    if (!result) {
-        result = @"";
-    }
-    return result;
-}
-
--(void)dealloc {
-       [name release];
-       [parent release];
-       [folders release];
-    [sharing release];
-       [objects release];
-    [sortedContents release];
-    [contentType release];
-       [super dealloc];
 }
 
 @end
index b6af52d..98254c3 100755 (executable)
@@ -6,13 +6,11 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <UIKit/UIKit.h>
 #import "OpenStackViewController.h"
 
 @class OpenStackAccount, Container, Folder, ActivityIndicatorView, ContainersViewController, FolderDetailViewController, StorageObjectViewController;
 
 @interface FolderViewController : OpenStackViewController <UITableViewDelegate, UITableViewDataSource, UIActionSheetDelegate> {
-    
     OpenStackAccount *account;
     Container *container;
     Folder *folder;
index 242f4c9..e305b56 100755 (executable)
 #import <MobileCoreServices/MobileCoreServices.h>
 #import "ComputeModel.h"
 
-
 @implementation FolderViewController
 
 @synthesize account, container, folder, containersViewController, selectedContainerIndexPath, contentsLoaded, parentFolderViewController, selectedFolderIndexPath, tableView, needsRefreshing, folderHasBeenRemoved, refreshWhenAppeared, folderDetailVC, selectedObjectViewController, refreshButton;
 
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
-    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait);
-}
-
-#pragma mark -
-#pragma mark View lifecycle
+#pragma mark - View lifecycle
 
 - (void)viewDidLoad {
     [super viewDidLoad];
     [self addAddButton];
     [self addHomeButton];
-    
-    deleteActionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure you want to delete this folder?  This operation cannot be undone." delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete Folder" otherButtonTitles:nil];
+    deleteActionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure you want to delete this folder? This operation cannot be undone." delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete Folder" otherButtonTitles:nil];
 }
 
 - (void)viewWillAppear:(BOOL)animated {
             if (needsRefreshing) 
                 self.parentFolderViewController.needsRefreshing = YES;
             [self.navigationController popViewControllerAnimated:YES];
+        } else {
+            [self refreshButtonPressed:nil];
         }
-        else
+    } else if (self.needsRefreshing) {
+        self.parentFolderViewController.needsRefreshing = YES;
+        if (refreshWhenAppeared) {
             [self refreshButtonPressed:nil];
-    } else {
-        if (self.needsRefreshing) {
-            self.parentFolderViewController.needsRefreshing = YES;
-            if (refreshWhenAppeared) {
-                [self refreshButtonPressed:nil];
-                refreshWhenAppeared = NO;
-            }
-            if (account.shared && ([folder.folders count] + [folder.objects count] == 0)) {
-                [self.navigationController popViewControllerAnimated:YES];
-            }
+            refreshWhenAppeared = NO;
+        }
+        if (account.shared && ([folder.folders count] + [folder.objects count] == 0)) {
+            [self.navigationController popViewControllerAnimated:YES];
         }
     }
 }
 
 - (void)viewWillDisappear:(BOOL)animated {
     [super viewWillDisappear:animated];
-    if (![self.navigationController.viewControllers containsObject:self]) {
-        if (self.parentViewController && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
-            [parentFolderViewController setDetailViewController];
-    }
-    if (!(folder.name && ![@"" isEqualToString:folder.name])) {
-//        [self.containersViewController.tableView deselectRowAtIndexPath:self.selectedContainerIndexPath animated:YES];
+    if (![self.navigationController.viewControllers containsObject:self] &&
+        self.parentViewController &&
+        (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)) {
+        [parentFolderViewController setDetailViewController];
     }
 }
 
+#pragma mark - Memory management
+
+- (void)dealloc {
+    [account release];
+    [container release];
+    [folder release];
+    [containersViewController release];
+    [selectedContainerIndexPath release];
+    [deleteActionSheet release];
+    [parentFolderViewController release];
+    [selectedFolderIndexPath release];
+    [refreshButton release];
+    [super dealloc];
+}
+
+#pragma mark - Actions
+
 - (void)setDetailViewController {
     if ([self.folder isEqual:self.container.rootFolder]) {
         ContainerDetailViewController *vc = [[ContainerDetailViewController alloc] initWithNibName:@"ContainerDetailViewController" bundle:nil];
         self.containersViewController.containerDetailViewController = vc;
         [vc release];
     } else {
-        FolderDetailViewController *folderDetailViewController = [[FolderDetailViewController alloc] initWithNibName:@"FolderDetailViewController" bundle:nil];
-        folderDetailViewController.account = account;
-        folderDetailViewController.container = container;
-        folderDetailViewController.folder = self.folder;
-        folderDetailViewController.folderViewController = self.parentFolderViewController;
-        [self presentPrimaryViewController:folderDetailViewController];
-        self.parentFolderViewController.folderDetailVC = folderDetailViewController;
-        [folderDetailViewController release];
+        FolderDetailViewController *vc = [[FolderDetailViewController alloc] initWithNibName:@"FolderDetailViewController" bundle:nil];
+        vc.account = self.account;
+        vc.container = self.container;
+        vc.folder = self.folder;
+        vc.folderViewController = self.parentFolderViewController;
+        [self presentPrimaryViewController:vc];
+        self.parentFolderViewController.folderDetailVC = vc;
+        [vc release];
     }
 }
 
-
-- (void)reloadFolderViewControllers
-{
+- (void)reloadFolderViewControllers {
     NSArray *viewControllers = [self.navigationController viewControllers];
     
     int rootFolderControllerIndex = [viewControllers indexOfObject:self.containersViewController] + 1;
         folderViewController.folder = [parentFolder.folders objectForKey:folderViewController.folder.name];
         if (folderViewController.folder) {
             [folderViewController.tableView reloadData];
-        }
-        else {
+        } else {
             folderViewController.folderHasBeenRemoved = YES;
         }
     }
             self.parentFolderViewController.needsRefreshing = YES;
         }
         [self.navigationController popViewControllerAnimated:YES];
-    } else {
-        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && account.shared)
-            [self setDetailViewController];
+    } else if ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) && account.shared) {
+        [self setDetailViewController];
     }
 }
 
-
-
-#pragma mark -
-#pragma mark Table view data source
-
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView {
-    return 1;
-}
-
+#pragma mark - UITableViewDataSource
 
 - (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
     return MAX(contentsLoaded ? 1 : 0, [folder.objects count] + [folder.folders count]);
     }
 }
 
-
-// Customize the appearance of table view cells.
-
 - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     if ([folder.objects count] + [folder.folders count] == 0) {
         NSString *noFoldersTitle = (self.account.shared || self.account.sharingAccount) ?
     }        
 }
 
-#pragma mark -
-#pragma mark Table view delegate
+#pragma mark - UITableViewDelegate
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     if ([folder.objects count] + [folder.folders count] > 0) {
     [vc release];
 }
 
-#pragma mark -
-#pragma mark Buttons
+#pragma mark - Button Handlers
 
 - (IBAction)homeButtonPressed:(id)sender {
     [self.navigationController popToViewController:containersViewController.accountHomeViewController animated:YES];
     [activityIndicatorView addToView:self.view];
     
     [self.account.manager getObjects:self.container];
-    successObserver = [[NSNotificationCenter defaultCenter] addObserverForName:@"getObjectsSucceeded" object:self.container
-                                                                         queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification* notification) 
-                       {   
-                           [activityIndicatorView removeFromSuperviewAndRelease];
-                           contentsLoaded = YES;
-                           [self.containersViewController refreshButtonPressed:nil];
-                           [self reloadFolderViewControllers];
-                           needsRefreshing = NO;
-                           if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
-                               if (self.selectedObjectViewController) {
-                                   [self.selectedObjectViewController reloadMetadataSection];
-                               } else if ([self.folder isEqual:container.rootFolder]) {
-                                   [containersViewController.containerDetailViewController reloadMetadataSection];
-                               } else if ([parentFolderViewController.folderDetailVC.navigationController.topViewController 
-                                           isEqual:parentFolderViewController.folderDetailVC]) {
-                                   [parentFolderViewController.folderDetailVC reloadMetadataSection];
-                               }
-                           }
-                           [[NSNotificationCenter defaultCenter] removeObserver:successObserver];
-                       }];
-    
-    failureObserver = [[NSNotificationCenter defaultCenter] addObserverForName:@"getObjectsFailed" object:self.container
-                                                                         queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification* notification) 
-                       {
-                           needsRefreshing = NO;
-                           [self.tableView reloadData]; 
-                           [activityIndicatorView removeFromSuperviewAndRelease];
-                           [self alert:@"Error" message:@"Failed to retrieve files from server"];
-                           [[NSNotificationCenter defaultCenter] removeObserver:failureObserver];
-                       }];
-    
-    
+    successObserver = [[NSNotificationCenter defaultCenter] addObserverForName:@"getObjectsSucceeded"
+                                                                        object:self.container
+                                                                         queue:[NSOperationQueue mainQueue]
+                                                                    usingBlock:^(NSNotification* notification)
+    {
+        [activityIndicatorView removeFromSuperviewAndRelease];
+        contentsLoaded = YES;
+        [self reloadFolderViewControllers];
+        needsRefreshing = NO;
+        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+           if (self.selectedObjectViewController) {
+               [self.selectedObjectViewController reloadMetadataSection];
+           } else if ([self.folder isEqual:container.rootFolder]) {
+               [containersViewController.containerDetailViewController reloadMetadataSection];
+           } else if ([parentFolderViewController.folderDetailVC.navigationController.topViewController 
+                       isEqual:parentFolderViewController.folderDetailVC]) {
+               [parentFolderViewController.folderDetailVC reloadMetadataSection];
+           }
+        }
+        [[NSNotificationCenter defaultCenter] removeObserver:successObserver];
+    }];
+    failureObserver = [[NSNotificationCenter defaultCenter] addObserverForName:@"getObjectsFailed"
+                                                                        object:self.container
+                                                                         queue:[NSOperationQueue mainQueue]
+                                                                    usingBlock:^(NSNotification* notification)
+    {
+        needsRefreshing = NO;
+        [self.tableView reloadData];
+        [activityIndicatorView removeFromSuperviewAndRelease];
+        [self alert:@"Error" message:@"Failed to retrieve files from server"];
+        [[NSNotificationCenter defaultCenter] removeObserver:failureObserver];
+    }];
 }
 
 - (void)addButtonPressed:(id)sender {
     [deleteActionSheet showInView:appDelegate.masterNavigationController.view];    
 }
 
-#pragma mark -
-#pragma mark Action Sheet Delegate
+#pragma mark - UIActionSheetDelegate
 
 - (void)deleteFolderRow {
     [self.parentFolderViewController.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:selectedFolderIndexPath] withRowAnimation:UITableViewRowAnimationLeft];
     }
 }
 
-#pragma mark -
-#pragma mark Memory management
-
-- (void)dealloc {
-    [account release];
-    [container release];
-    [folder release];
-    [containersViewController release];
-    [selectedContainerIndexPath release];
-    [deleteActionSheet release];
-    [parentFolderViewController release];
-    [selectedFolderIndexPath release];
-    [refreshButton release];
-    [super dealloc];
-}
-
-
 @end
 
index 4092f17..8cdc259 100755 (executable)
 }
 
 + (id)filesRequest:(OpenStackAccount *)account method:(NSString *)method path:(NSString *)path {
-    NSString *now = [[[NSDate date] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-       NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@?format=json%@&now=%@",
+       NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@?format=json%@",
                                        account.filesURL,
                                        path,
-                                       account.shared ? @"&shared=" : @"",
-                                       now]];
+                                       account.shared ? @"&shared=" : @""]];
     
     return [GetContainersRequest request:account method:method url:url];
 }
index b5f8398..4f16f93 100755 (executable)
@@ -29,8 +29,6 @@
 }
 
 + (id)filesRequest:(OpenStackAccount *)account method:(NSString *)method path:(NSString *)path marker:(NSString *)marker {
-    NSString *now = [[[NSDate date] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-    
     NSString *filesUrl;
     NSString *urlString = [account.filesURL description];
     if (account.sharingAccount) {
     } else
         filesUrl = urlString;
     
-       NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@?format=json%@%@&now=%@",
+       NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@?format=json%@%@",
                                        filesUrl,
                                        path,
                                        account.shared ? @"&shared=" : @"",
-                                       marker ? [NSString stringWithFormat:@"&marker=%@", marker] : @"",
-                                       now]];
+                                       marker ? [NSString stringWithFormat:@"&marker=%@", marker] : @""]];
 
     return [GetObjectsRequest request:account method:method url:url];
 }
index 360edb3..2708e7f 100755 (executable)
@@ -4,8 +4,6 @@
 //  Created by Mike Mayo on 8/3/10.
 //
 
-#import <Foundation/Foundation.h>
-
 @interface NSObject (Conveniences)
 
 + (NSString *)stringWithUUID;
index 8f30e9b..e724fa9 100755 (executable)
@@ -6,8 +6,6 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <Foundation/Foundation.h>
-
 @interface NSObject (NSCoding)
 
 - (void)autoEncodeWithCoder:(NSCoder *)coder;
index 6fbd7a3..6d65615 100755 (executable)
@@ -6,9 +6,6 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <Foundation/Foundation.h>
-
-
 @interface NSString (Conveniences)
 
 - (BOOL)isURL;
index a8dd317..4792a11 100755 (executable)
@@ -8,7 +8,6 @@
 
 #import "NSString+Conveniences.h"
 
-
 @implementation NSString (Conveniences)
 
 - (BOOL)isURL {
index 6ac8a3b..8a0b233 100755 (executable)
@@ -127,19 +127,16 @@ static NSRecursiveLock *accessDetailsLock = nil;
 }
 
 + (id)filesRequest:(OpenStackAccount *)account method:(NSString *)method path:(NSString *)path {
-    NSString *now = [[[NSDate date] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-    
     NSString *urlString = [account.filesURL description];
     if (account.sharingAccount) {
         NSRange authUserRange = [urlString rangeOfString:account.username];
         urlString = [NSString stringWithFormat:@"%@%@", [urlString substringToIndex:authUserRange.location], account.sharingAccount];
     }
     
-       NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@?format=json%@&now=%@",
+       NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@?format=json%@",
                                        urlString,
                                        path,
-                                       account.shared ? @"&shared=" : @"",
-                                       now]];
+                                       account.shared ? @"&shared=" : @""]];
     
     return [OpenStackRequest request:account method:method url:url];
 }
index ae8e241..cbe4249 100644 (file)
@@ -35,8 +35,6 @@
 // interpreted as representing official policies, either expressed
 // or implied, of GRNET S.A.
 
-#import <UIKit/UIKit.h>
-
 @interface PithosImageViewController : UIViewController {
 }
 
index b067e97..4c39971 100755 (executable)
@@ -6,8 +6,6 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <UIKit/UIKit.h>
-
 @class RootViewController;
 
 @interface ProvidersViewController : UITableViewController {
index 1318779..551b39c 100755 (executable)
@@ -6,9 +6,6 @@
 //  Copyright 2011 __MyCompanyName__. All rights reserved.
 //
 
-#import <UIKit/UIKit.h>
-
-
 @interface RSTextFieldCell : UITableViewCell {
     UITextField *textField;
     UIModalPresentationStyle modalPresentationStyle;
index 09b0b0f..32208ad 100755 (executable)
@@ -9,7 +9,6 @@
 #import "RSTextFieldCell.h"
 #import "UIColor+MoreColors.h"
 
-
 @implementation RSTextFieldCell
 
 @synthesize textField, modalPresentationStyle, fixedTextLabel;
index af2405b..dcc7e0d 100755 (executable)
@@ -6,9 +6,6 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <Foundation/Foundation.h>
-
-
 @interface StorageObject : NSObject <NSCoding> {
        NSString *name;
     NSString *fullPath;
 @property (nonatomic, retain) NSString *lastModifiedString;
 @property (nonatomic, retain) NSMutableDictionary *metadata;
 
-- (NSString *)humanizedBytes;
 + (StorageObject *)fromJSON:(NSDictionary *)dict;
 - (void)setPropertiesfromResponseHeaders:(NSDictionary *)headers;
-
+- (NSString *)humanizedBytes;
 - (BOOL)isPlayableMedia;
 
 @end
index d843df7..14db7a8 100755 (executable)
 
 @synthesize name, fullPath, hash, bytes, contentType, lastModified, data, publicURI, sharing, metadata, iso8601DateString, lastModifiedString;
 
-#pragma mark -
-#pragma mark Serialization
-
-- (void)encodeWithCoder:(NSCoder *)coder {
-    [self autoEncodeWithCoder:coder];
-    /*
-    [coder encodeObject:name forKey:@"name"];
-    [coder encodeObject:fullPath forKey:@"fullPath"];
-    [coder encodeObject:hash forKey:@"hash"];
-    [coder encodeInt:bytes forKey:@"bytes"];
-    [coder encodeObject:contentType forKey:@"contentType"];
-    [coder encodeObject:lastModified forKey:@"lastModified"];
-    // not persisting data to save space
-    [coder encodeObject:metadata forKey:@"metadata"];
-     */
-}
-
-- (id)initWithCoder:(NSCoder *)coder {
-    self = [super init];
-    if (self) {
-        [self autoDecode:coder];
-        /*
-        name = [[coder decodeObjectForKey:@"name"] retain];
-        fullPath = [[coder decodeObjectForKey:@"fullPath"] retain];
-        hash = [[coder decodeObjectForKey:@"hash"] retain];
-        bytes = [coder decodeIntForKey:@"bytes"];
-        contentType = [[coder decodeObjectForKey:@"contentType"] retain];
-        lastModified = [[coder decodeObjectForKey:@"lastModified"] retain];
-        data = [[coder decodeObjectForKey:@"data"] retain];
-        metadata = [[coder decodeObjectForKey:@"metadata"] retain];
-         */
-    }
-    return self;
-}
-
-#pragma mark -
-#pragma mark JSON
+#pragma mark - Object lifecycle
 
 + (StorageObject *)fromJSON:(NSDictionary *)dict {
     StorageObject *object = [[[StorageObject alloc] init] autorelease];
     object.iso8601DateString = [dict objectForKey:@"last_modified"];
     object.publicURI = [dict objectForKey:@"x_object_public"];
     object.sharing = [dict objectForKey:@"x_object_sharing"];
-    object.metadata = nil;       
+    object.metadata = nil;
     return object;
 }
 
+- (NSComparisonResult)compare:(StorageObject *)anObject {
+    return [self.name caseInsensitiveCompare:anObject.name];
+}
+
+#pragma mark - Serialization
+
+- (id)initWithCoder:(NSCoder *)coder {
+    if ((self = [super init])) {
+        [self autoDecode:coder];
+    }
+    return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder {
+    [self autoEncodeWithCoder:coder];
+}
+
+#pragma mark - Memory Management
+
+-(void)dealloc {
+       [name release];
+    [fullPath release];
+       [hash release];
+       [contentType release];
+       [lastModified release];
+       [data release];
+       [metadata release];
+    [iso8601DateString release];
+    [lastModifiedString release];
+       [super dealloc];
+}
+
+#pragma mark - Properties
+
+- (NSString *)lastModifiedString {
+    if (!lastModifiedString) {
+        if (!self.lastModified && [self.iso8601DateString length])
+            self.lastModified = [ComputeModel dateFromString:self.iso8601DateString];
+        if (self.lastModified)
+            lastModifiedString = [[ComputeModel localDateDescriptionFromDate:self.lastModified] retain];
+    }
+    return lastModifiedString;
+}
+
+#pragma mark - Actions
+
 - (void)setPropertiesfromResponseHeaders:(NSDictionary *)headers {
     self.hash = [headers objectForKey:@"X-Object-Hash"];
     self.bytes = [[headers objectForKey:@"Content-Length"] intValue];
@@ -86,9 +96,6 @@
     }
 }
 
-#pragma mark -
-#pragma mark Presentation
-
 -(NSString *)humanizedBytes {
        NSString *result;       
        if (self.bytes >= 1024000000) {
 }
 
 - (BOOL)isPlayableMedia {
-    
     // check file extension
     NSString *extensionPattern = @"^.+\\.((mov)|(m4a)|(mp3)|(wav)|(aiff)|(aac)|(aif)|(aifc)|(amr)|(caf)|(m2a)|(m4p)|(mp4)|(mpv)|(3gp))$";
     NSRegularExpression *extensionRegex = [NSRegularExpression regularExpressionWithPattern:extensionPattern options:NSRegularExpressionCaseInsensitive error:nil];
     return matches > 0;
 }
 
-- (NSComparisonResult)compare:(StorageObject *)anObject {
-    return [self.name caseInsensitiveCompare:anObject.name];
-}
-
-#pragma mark -
-#pragma mark Properties
-
-- (NSString *)lastModifiedString {
-    if (!lastModifiedString) {
-        if (!self.lastModified && [self.iso8601DateString length])
-            self.lastModified = [ComputeModel dateFromString:self.iso8601DateString];
-        if (self.lastModified)
-            lastModifiedString = [[ComputeModel localDateDescriptionFromDate:self.lastModified] retain];
-    }
-    return lastModifiedString;
-}
-
-#pragma mark -
-#pragma mark Memory Management
-
--(void)dealloc {
-       [name release];
-    [fullPath release];
-       [hash release];
-       [contentType release];
-       [lastModified release];
-       [data release];
-       [metadata release];
-    [iso8601DateString release];
-    [lastModifiedString release];
-       [super dealloc];
-}
-
 @end
index 310a2cb..a1b1c6f 100755 (executable)
@@ -6,9 +6,6 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <UIKit/UIKit.h>
-
-
 @interface TextViewCell : UITableViewCell {
     UITextView *textView;
 }
index 5667f38..c4d68f2 100755 (executable)
@@ -8,7 +8,6 @@
 
 #import "TextViewCell.h"
 
-
 @implementation TextViewCell
 
 @synthesize textView;
@@ -30,7 +29,6 @@
     return self;
 }
 
-
 //- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
 //    
 //    [super setSelected:selected animated:animated];
@@ -43,7 +41,6 @@
 //    }
 //}
 
-
 - (void)dealloc {
     [textView release];
     [super dealloc];
index 95c08f2..9254da0 100755 (executable)
@@ -6,9 +6,6 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <Foundation/Foundation.h>
-
-
 @interface UIColor (MoreColors)
 
 + (UIColor *)value1DetailTextLabelColor;
index 77f1e2e..ddf10f5 100755 (executable)
@@ -8,7 +8,6 @@
 
 #import "UIColor+MoreColors.h"
 
-
 @implementation UIColor (MoreColors)
 
 + (UIColor *)value1DetailTextLabelColor {
index 1ac6cd2..64cae38 100755 (executable)
@@ -4,8 +4,6 @@
 //  Created by Mike Mayo on 7/21/10.
 //
 
-#import <Foundation/Foundation.h>
-
 @class OpenStackRequest;
 
 @interface UIViewController (Conveniences) <UIAlertViewDelegate>
diff --git a/main.m b/main.m
index a04090b..3aed94b 100755 (executable)
--- a/main.m
+++ b/main.m
@@ -6,8 +6,6 @@
 //  The OpenStack project is provided under the Apache 2.0 license.
 //
 
-#import <UIKit/UIKit.h>
-
 int main(int argc, char *argv[]) {
     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     int retVal = UIApplicationMain(argc, argv, nil, nil);