2 // DeviceTableViewController.m
8 #import "DeviceTableViewController.h"
9 #import "DeviceItemCell.h"
11 static NSString *redCircle = @"🔴";
12 static NSString *blueCircle = @"🔵";
16 KCA_ITEM_STATUS_ID = 300,
17 KCA_ITEM_NAME_ID = 301,
18 KCA_ITEM_ACCT_ID = 302,
21 @interface DeviceTableViewController ()
25 @implementation DeviceTableViewController
27 - (id)initWithStyle:(UITableViewStyle)style
29 NSLog(@"DeviceTableViewController: initWithStyle");
30 if (self = [super initWithStyle:style])
32 // Custom initialization
33 // [self.tableView registerClass:(Class)[KeychainItemCell class] forCellReuseIdentifier:(NSString *)@"kciCell"];
35 _kcItemStatuses = [[NSArray alloc] initWithObjects:@"",redCircle, blueCircle,@"",@"",blueCircle,nil];
36 _kcItemNames = [[NSArray alloc] initWithObjects:@"Facebook",@"iCloud", @"WSJ",@"Twitter",@"NYTimes",@"Wells Fargo", nil];
37 // self.navigationItem.rightBarButtonItem = self.editButtonItem;
45 NSLog(@"DeviceTableViewController: viewDidLoad");
48 // Uncomment the following line to preserve selection between presentations.
49 // self.clearsSelectionOnViewWillAppear = NO;
50 _kcItemStatuses = [[NSArray alloc] initWithObjects:@"",redCircle, blueCircle,@"",@"",nil];
51 _kcItemNames = [[NSArray alloc] initWithObjects:@"Facebook",@"iCloud", @"WSJ",@"Twitter",@"NYTimes",nil];
53 // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
54 self.navigationItem.rightBarButtonItem = self.editButtonItem;
58 - (void)didReceiveMemoryWarning
60 [super didReceiveMemoryWarning];
61 // Dispose of any resources that can be recreated.
64 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
66 if ([[segue identifier] isEqualToString:@"ItemDetail"])
69 KCAItemDetailViewController *detailViewController = [segue destinationViewController];
70 NSIndexPath *myIndexPath = [self.tableView indexPathForSelectedRow];
71 int row = [myIndexPath row];
72 //TODO - horribly inefficient !
73 NSArray *items = [self getItems];
74 detailViewController.itemDetailModel = [items objectAtIndex: row];
79 // MARK: - Table view data source
83 NSArray *allItems = NULL;//(NSArray *)[[MyKeychain sharedInstance] fetchDictionaryAll];
87 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
89 // Return the number of sections.
90 NSLog(@"numberOfSectionsInTableView");
94 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
96 // Return the number of rows in the section.
98 // SOSCircleCountPeers(circle) + SOSCircleCountApplicants(circle)
100 static bool dumpedit = false;
104 NSMutableDictionary *allItems = NULL;//[[MyKeychain sharedInstance] fetchDictionaryAll];
105 NSLog(@"numberOfRowsInSection: items: %lu", (unsigned long)[allItems count]);
111 return _kcItemStatuses.count;
113 NSInteger count = [[self getItems] count];
114 NSLog(@"numberOfRowsInSection: %ld", (long)count);
121 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
124 NSLog(@"cellForRowAtIndexPath %@", indexPath);
126 //- (id)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(6_0); // newer dequeue method guarantees a cell is returned and resized properly, assuming identifier is registered
128 // KeychainItemCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
130 // UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:KCAItemCellIdentifier forIndexPath:(NSIndexPath *)indexPath];
131 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"deviceTableCell" forIndexPath:(NSIndexPath *)indexPath];
134 NSLog(@"cellForRowAtIndexPath : cell was nil");
135 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"deviceTableCell"];
138 // Configure the cell...
140 NSUInteger row = [indexPath row];
143 UILabel *statusLabel = (UILabel *)[cell viewWithTag:KCA_ITEM_STATUS_ID];
144 statusLabel.text = [_kcItemStatuses objectAtIndex: row];
145 UILabel *nameLabel = (UILabel *)[cell viewWithTag:KCA_ITEM_NAME_ID];
146 nameLabel.text = [_kcItemNames objectAtIndex: row];
148 NSArray *items = [self getItems];
149 NSDictionary *theItem = [items objectAtIndex: row];
150 UILabel *statusLabel = (UILabel *)[cell viewWithTag:KCA_ITEM_STATUS_ID];
151 statusLabel.text = [_kcItemStatuses objectAtIndex: row];
152 UILabel *nameLabel = (UILabel *)[cell viewWithTag:KCA_ITEM_NAME_ID];
153 nameLabel.text = [theItem objectForKey: (__bridge id)(kSecAttrService)];
154 UILabel *accountLabel = (UILabel *)[cell viewWithTag:KCA_ITEM_ACCT_ID];
155 accountLabel.text = [theItem objectForKey: (__bridge id)(kSecAttrAccount)];
159 WHY DOESNT THIS WORK !!!
160 cell.itemAccount.text =
161 cell.itemStatus.text =
162 cell.itemName.text = [_kcItemNames objectAtIndex: [indexPath row]];
166 static NSString *CellIdentifier = @"DeviceCell";
167 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
169 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
172 // Configure the cell...
173 // cell.textLabel.text = @"1234";
174 cell.textLabel.text = self.objects[indexPath.row];