aboutsummaryrefslogtreecommitdiffhomepage
path: root/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m
diff options
context:
space:
mode:
Diffstat (limited to 'example/ios/iOS UI Test/iOS UI Test/MasterViewController.m')
-rw-r--r--example/ios/iOS UI Test/iOS UI Test/MasterViewController.m102
1 files changed, 102 insertions, 0 deletions
diff --git a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m
new file mode 100644
index 00000000..7a76efa7
--- /dev/null
+++ b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m
@@ -0,0 +1,102 @@
+//
+// MasterViewController.m
+// iOS UI Test
+//
+// Created by Jonathan Willing on 4/8/13.
+// Copyright (c) 2013 AppJon. All rights reserved.
+//
+
+#import "MasterViewController.h"
+#import "DetailViewController.h"
+#import <MailCore/MailCore.h>
+#import "FXKeychain.h"
+
+@interface MasterViewController () {
+ NSMutableArray *_objects;
+}
+@property (nonatomic, strong) MCOIMAPOperation *imapCheckOp;
+@property (nonatomic, strong) MCOIMAPSession *imapSession;
+@end
+
+@implementation MasterViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ self.navigationItem.leftBarButtonItem = self.editButtonItem;
+
+ NSString *username = [[NSUserDefaults standardUserDefaults] objectForKey:UsernameKey];
+ NSString *password = [FXKeychain defaultKeychain][PasswordKey];
+
+ self.imapSession = [[MCOIMAPSession alloc] init];
+ self.imapSession.hostname = @"imap.gmail.com";
+ self.imapSession.port = 993;
+ self.imapSession.username = username;
+ self.imapSession.password = password;
+ self.imapSession.connectionType = MCOConnectionTypeTLS;
+}
+
+- (void)didReceiveMemoryWarning {
+ [super didReceiveMemoryWarning];
+ NSLog(@"%s",__PRETTY_FUNCTION__);
+}
+
+- (void)insertNewObject:(id)sender {
+ if (!_objects) {
+ _objects = [[NSMutableArray alloc] init];
+ }
+ [_objects insertObject:[NSDate date] atIndex:0];
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
+ [self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
+}
+
+#pragma mark - Table View
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+ return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+ return _objects.count;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
+
+ NSDate *object = _objects[indexPath.row];
+ cell.textLabel.text = [object description];
+ return cell;
+}
+
+- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
+ // Return NO if you do not want the specified item to be editable.
+ return YES;
+}
+
+- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
+ if (editingStyle == UITableViewCellEditingStyleDelete) {
+ [_objects removeObjectAtIndex:indexPath.row];
+ [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
+ } else if (editingStyle == UITableViewCellEditingStyleInsert) {
+ // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
+ }
+}
+
+- (void)showSettingsViewController:(id)sender {
+ SettingsViewController *settingsViewController = [[SettingsViewController alloc] initWithNibName:nil bundle:nil];
+ settingsViewController.delegate = self;
+ [self presentViewController:settingsViewController animated:YES completion:nil];
+}
+
+- (void)settingsViewControllerFinished:(SettingsViewController *)viewController {
+ [self dismissViewControllerAnimated:YES completion:nil];
+}
+
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+ if ([[segue identifier] isEqualToString:@"showDetail"]) {
+ NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
+ NSDate *object = _objects[indexPath.row];
+ [[segue destinationViewController] setDetailItem:object];
+ }
+}
+
+@end