Skip to content

Instantly share code, notes, and snippets.

@mattfinlayson
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattfinlayson/7cfd8b5ddedde896e1ba to your computer and use it in GitHub Desktop.
Save mattfinlayson/7cfd8b5ddedde896e1ba to your computer and use it in GitHub Desktop.
Snippets from BaasBox and Swift - Part 2
[SMPost getObjectsWithCompletion:^(NSArray *objects, NSError *error) {
_posts = [objects mutableCopy];
[self.tableView reloadData];
}];
SMPost.getObjectsWithCompletion({ (objects: [AnyObject]!, error: NSError!) -> Void in
self.posts = NSMutableArray(array: objects)
self.tableView.reloadData()
})
import Foundation
class SMLoginViewController : UIViewController {
@IBOutlet weak var loginView: UIView!
@IBOutlet weak var signupView: UIView!
@IBOutlet weak var segmentedControl: UISegmentedControl!
@IBOutlet weak var loginUsernameField: UITextField!
@IBOutlet weak var loginPasswordField: UITextField!
@IBOutlet weak var signupUsernameField: UITextField!
@IBOutlet weak var signupPasswordField: UITextField!
// MARK: - Public API
@IBAction func login() {
NSLog("Login")
}
@IBAction func signup() {
NSLog("Signup")
}
//
// SMLoginViewController.h
// DearDiary
//
// Created by Cesare Rocchi on 9/26/13.
// Copyright (c) 2013 Cesare Rocchi. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SMLoginViewController : UIViewController
@property (weak) IBOutlet UIView *loginView;
@property (weak) IBOutlet UIView *signupView;
@property (weak) IBOutlet UISegmentedControl *segmentedControl;
@property (weak) IBOutlet UITextField *loginUsernameField;
@property (weak) IBOutlet UITextField *loginPasswordField;
@property (weak) IBOutlet UITextField *signupUsernameField;
@property (weak) IBOutlet UITextField *signupPasswordField;
- (IBAction) login;
- (IBAction) signup;
@end
import Foundation
class SMPost: BAAObject {
var postTitle: String!
var postBody: String!
override init(dictionary: [NSObject : AnyObject]!) {
super.init(dictionary: dictionary)
if let
actualPostTitle = dictionary["postTitle"] as? String,
actualPostBody = dictionary["postBody"] as? String {
postTitle = actualPostTitle
postBody = actualPostBody
}
}
override func collectionName() -> String! {
return "document/memos"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment