小编mih*_*tel的帖子

我应该使用存储库for Realm(ios)

首先,我在ios中相对较新,没有任何使用移动dbs的经验.

想要集成到我的应用程序Realm(swift),并想知道将服务层和存储库分开或者所有内容都包含在服务中是否有意义.

一些例子有一个很好的观点.

class UserService {

    var userRepository: UserRepository!

    func findById(userId: String) -> User? {
        return userRepository.findById(userId: userId)
    }
}

class UserRepository {

    private let realm = try! Realm()

    func findById(userId: String) -> User? {
        return realm.object(ofType: User.self, forPrimaryKey: userId)
    }
}
Run Code Online (Sandbox Code Playgroud)

service repository realm ios swift

8
推荐指数
1
解决办法
993
查看次数

jhipster会话超时配置

我从git下载了JHipster,并尝试了解如何配置会话超时但无法找到任何web.xml基于java的类.

你能帮我解决一下如何配置session超时,例如20分钟吗?

security spring angularjs jhipster

6
推荐指数
1
解决办法
5369
查看次数

键盘将显示两次

我遇到了问题“keyboardWillShow”触发两次,但“keyboardWillHide”调用一次。

这是一个示例,其中我在“keyboardWillShow”触发后立即打印键盘尺寸。我还在“viewDidLoad”中放置了断点,并且观察者仅注册一次。我添加了两个元素“UITextField”和“UITextView”,两者的行为相同。

我正在使用 iOS 9.2、swift 语言、xcode 7

在我的 ViewController 下面

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name: UIKeyboardWillShowNotification, object: nil)
    NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide:"), name: UIKeyboardWillHideNotification, object: nil)
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func keyboardWillShow(notification: NSNotification) {
    if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
        print("keyboardWillShow sizes: \(keyboardSize)")
    } …
Run Code Online (Sandbox Code Playgroud)

keyboard-events ios swift

5
推荐指数
1
解决办法
3613
查看次数

如果使用 CoreData 是否需要缓存

首先,我是 ios/swift 的新手...

我需要有我的应用程序的离线模式。

我正在使用 Alamofire 进行所有网络获取 json、转换为对象并保存到数据库(核心数据)中。想知道在没有互联网连接或从 CoreData 获取的情况下,我是否需要在两者之间添加额外的缓存(例如:HanekeDataCache)?

数据库请求是否足够快/方便?

caching core-data swift alamofire haneke

5
推荐指数
1
解决办法
2488
查看次数

Swift UITableView分隔符不可见

我是ios/swft的新手,遇到了在表视图中显示分隔符的问题.我已经花了几天时间尝试了几乎所有的建议,但它们都不适合我.我正在动态插入单元格,在这种情况下,分隔符会消失.在我正在使用的代码下面.

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    @IBOutlet weak var tableView: UITableView!

    let tableData = ["One","Two","Three"]


    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        tableView.delegate = self
        tableView.dataSource = self
    }


    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return tableData.count
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = …
Run Code Online (Sandbox Code Playgroud)

uitableview separator ios swift

3
推荐指数
1
解决办法
6279
查看次数