Skip to content

Instantly share code, notes, and snippets.

View funkyboy's full-sized avatar

Cesare funkyboy

View GitHub Profile
- (instancetype) initWithDictionary:(NSDictionary *)dictionary {
self = [super initWithDictionary:dictionary];
if (self) {
_postTitle = dictionary[@"postTitle"];
_postBody = dictionary[@"postBody"];
}
- (NSString *)collectionName {
return @"document/memos";
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
BAAClient *client = [BAAClient sharedClient];
if (client.isAuthenticated) {
NSLog(@"Logged in");
BAAClient *client = [BAAClient sharedClient];
client.isAuthenticated
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
BAAClient *client = [BAAClient sharedClient];
if (client.isAuthenticated) {
NSLog(@"Logged in");
- (IBAction) login {
NSLog(@"login");
BAAClient *client = [BAAClient sharedClient];
[client authenticateUser:self.loginUsernameField.text
password:self.loginPasswordField.text
completion:^(BOOL success, NSError *error) {
- (void)createNewPost:(id)sender {
if (!_posts) {
_posts = [[NSMutableArray alloc] init];
}
SMPost *p = [[SMPost alloc] init];
p.postTitle = [NSString stringWithFormat:@"No title %i", _posts.count ];
p.postBody = @"No body";
- (void) savePost:(id)sender {
self.post.postTitle = self.titleField.text;
self.post.postBody = self.bodyTextView.text;
[self.post saveObjectWithCompletion:^(id object, NSError *error) {
if (error == nil) {
NSLog(@"object saved");
@interface SMPost : BAAObject
@property (copy) NSString *postTitle;
@property (copy) NSString *postBody;
@end
- (instancetype) initWithDictionary:(NSDictionary *)dictionary {
self = [super initWithDictionary:dictionary];
if (self) {
_postTitle = dictionary[@"postTitle"];
_postBody = dictionary[@"postBody"];
}