Skip to content

Adding Tables

cmancushman edited this page Oct 26, 2017 · 11 revisions

Create a Table

Declaration

+(void)createStackBaseTableWithName:(NSString *)name columns:(NSArray<StackBaseColumn *> *)columns withCompletionBlock:(StackBaseTableCompletion) compBlock;

Example

[StackBaseClient createStackBaseTableWithName:@"TestTable" 
columns:@[[StackBaseColumn textColumnWithName:@"Name"], [StackBaseColumn textColumnWithName:@"Memo"], [StackBaseColumn dateTimeColumnWithName:@"Timestamp" type:StackBaseDateTimeTypeTIMESTAMP]] 
withCompletionBlock:^(BOOL success, NSString *responseMessage, StackBaseTable *table) {

    if(success){

        weakSelf.table = table;

        NSLog(@"Table: %@", weakSelf.table);

    }else{

        NSLog(@"Operation Unsuccessful: %@", responseMessage);

    }

}];

Note
Repeated calls of this method will connect to the existing table found in your database rather than overwriting it with a new one.


Connect to a Table

Declaration

+(void)connectToStackBaseTableWithName:(NSString *)name withCompletionBlock:(StackBaseTableCompletion) compBlock;

Example

[StackBaseClient connectToStackBaseTableWithName:@"TestTable" 
withCompletionBlock:^(BOOL success, NSString *responseMessage, StackBaseTable *table) {

    if(success){

        NSLog(@"TestTable: %@", table);

    }else{

        NSLog(@"Operation Unsuccessful: %@", responseMessage);

    }

}];

Clone this wiki locally