swift BaasBox和Swift的片段 - 第2部分

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift BaasBox和Swift的片段 - 第2部分相关的知识,希望对你有一定的参考价值。

SMPost.getObjectsWithCompletion({ (objects: [AnyObject]!, error: NSError!) -> Void in
                self.posts = NSMutableArray(array: objects)
                self.tableView.reloadData()
            })
[SMPost getObjectsWithCompletion:^(NSArray *objects, NSError *error) {
 
    _posts = [objects mutableCopy];
    [self.tableView reloadData];
 
}];
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"
    }
}
//
//  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 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")
}

以上是关于swift BaasBox和Swift的片段 - 第2部分的主要内容,如果未能解决你的问题,请参考以下文章

swift常用代码片段

swift 代码片段

swift SWRevealController片段

iOS Swift 中的 Android 片段模拟

如何将这个 Objective-C 代码片段写入 Swift?

Swift新async/await并发中利用Task防止指定代码片段执行的数据竞争(Data Race)问题