I need help how to connect my SQLite database to my watchkit app extension. Im not much familiar in using sqlite with cell rows. Any easy sample codes will be a great help thanks. Below are sample arrays i used for example.
#import "ICBQuoteSource.h"
@implementation ICBQuoteSource
(NSArray *)quoteDictionary { NSMutableArray *quotes = [NSMutableArray new];
[quotes addObject:@{@"characterImage": @"moss", @"characterName": @"Moss", @"quote": @"I came here to drink milk and kick ass... and I've just finished my milk."}]; [quotes addObject:@{@"characterImage": @"roy", @"characterName": @"Roy", @"quote": @"Hello, IT, have you tried turning it off and on again?"}]; [quotes addObject:@{@"characterImage": @"moss", @"characterName": @"Moss", @"quote": @"Did you see that ludicrous display last night?"}]; [quotes addObject:@{@"characterImage": @"denholm", @"characterName": @"Denholm", @"quote": @"That's the sort of place this is, Jen. A lot of sexy people not doing much work and having affairs."}]; [quotes addObject:@{@"characterImage": @"moss", @"characterName": @"Moss", @"quote": @"This Jen is the Internet"}];
return [NSArray arrayWithArray:quotes]; }
@end
#import "InterfaceController.h"
import "ICBQuoteSource.h"
import "rowController.h"
@interface InterfaceController()
@property (nonatomic, strong) NSArray *quotes;
@end
@implementation InterfaceController
(void)awakeWithContext:(id)context { [super awakeWithContext:context];
// Get quotes self.quotes = [ICBQuoteSource quoteDictionary];
// Set number of table Row [self.table setNumberOfRows:self.quotes.count withRowType:@"Row Controller"];
// Set row properties for (NSDictionary *quote in self.quotes) {
rowController *quoteRow = [self.table rowControllerAtIndex:[self.quotes indexOfObject:quote]];
[quoteRow.englishTxtLabel setText:quote[@"characterName"]];
[quoteRow.translationTxtLabel setText:quote[@"quote"]];} }
(void)willActivate { // This method is called when watch view controller is about to be visible to user [super willActivate]; }
(void)didDeactivate { // This method is called when watch view controller is no longer visible [super didDeactivate]; }
@end
Aucun commentaire:
Enregistrer un commentaire