Last active
August 29, 2015 14:23
-
-
Save mattfinlayson/7cfd8b5ddedde896e1ba to your computer and use it in GitHub Desktop.
Snippets from BaasBox and Swift - Part 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[SMPost getObjectsWithCompletion:^(NSArray *objects, NSError *error) { | |
_posts = [objects mutableCopy]; | |
[self.tableView reloadData]; | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SMPost.getObjectsWithCompletion({ (objects: [AnyObject]!, error: NSError!) -> Void in | |
self.posts = NSMutableArray(array: objects) | |
self.tableView.reloadData() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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