Create ToDo using Realm—Expected member name or constructor call after type name

Asked 3 months ago, Updated 3 months ago, 9 views

[For beginners] Completely detailed!Tutorial to create a ToDo app with cocoapod+Realm (4 times in total) - Qiita

I made ToDo according to the tutorial on the page above, but in the code below, return realm.objects(ToDo),

Expected member name or constructor call after type name

You will see the error

I was able to resolve the other error, but I couldn't erase the error in this part.
Could you tell me how to solve this problem?

source code

import UIKit
import RealmSwift

classViewController:UIViewController {

  @IBOutlet var todoNameText:UITextField!

  @IBOutlet variableView:UITableView!

  var toDoItems:Results<ToDo>?{
      let realm = try Realm()
      return realm.objects (ToDo)
    }catch {
    return nil

swift realm

2022-09-30 11:38

1 Answers

Pass the class object (meta type) to the Realm.objects(_:) parameter.
Swift grammar requires .self after ToDo.self and ToDo.self to obtain the meta-type.

2022-09-30 11:38

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.