Using RealmSwift to create a pin code, trying to call RealmSwift functionHow to call Objective-C code from SwiftSwift 2: Call can throw, but it is not marked with 'try' and the error is not handledAdd TextField to UIAlertView in Swift that saves to a TableView controllerFirebase swift ios login system error Assertion failed/Exec_BAD_INSTRUNCTION (code=EXC_i386_INVOP, subcode=0x0)Update or reload UITableView after completion of delete action on detail viewHow to create relationship in RealmSwift?Attempt to present alertcontroller whose view is not in window hierarchySwift Error - Use of undeclared type 'cell' - Collection ViewHow to make root navigation bar transparent, but child navigation bars not?TableView Controller is hiding the dropshadow of swipemenu in swift 4

Not hide and seek

What is the tangent at a sharp point on a curve?

Has the laser at Magurele, Romania reached a tenth of the Sun's power?

Weird lines in Microsoft Word

Can a Knock spell open the door to Mordenkainen's Magnificent Mansion?

categorizing a variable turns it from insignificant to significant

Reasons for having MCU pin-states default to pull-up/down out of reset

What is the purpose of using a decision tree?

Magnifying glass in hyperbolic space

Why didn't Voldemort know what Grindelwald looked like?

How do I lift the insulation blower into the attic?

Trouble reading roman numeral notation with flats

How do you say "Trust your struggle." in French?

Hashing password to increase entropy

Sort with assumptions

Rendered textures different to 3D View

What is this high flying aircraft over Pennsylvania?

Can you take a "free object interaction" while incapacitated?

What is it called when someone votes for an option that's not their first choice?

Why does a 97 / 92 key piano exist by Bosendorfer?

Pre-Employment Background Check With Consent For Future Checks

Why is "la Gestapo" feminine?

Mortal danger in mid-grade literature

Error in master's thesis, I do not know what to do



Using RealmSwift to create a pin code, trying to call RealmSwift function


How to call Objective-C code from SwiftSwift 2: Call can throw, but it is not marked with 'try' and the error is not handledAdd TextField to UIAlertView in Swift that saves to a TableView controllerFirebase swift ios login system error Assertion failed/Exec_BAD_INSTRUNCTION (code=EXC_i386_INVOP, subcode=0x0)Update or reload UITableView after completion of delete action on detail viewHow to create relationship in RealmSwift?Attempt to present alertcontroller whose view is not in window hierarchySwift Error - Use of undeclared type 'cell' - Collection ViewHow to make root navigation bar transparent, but child navigation bars not?TableView Controller is hiding the dropshadow of swipemenu in swift 4













0















I am using RealmSwift to create a pin code object for an iOS app I am building.
I have created a constructor and a few basic functions to check the pin, enter new pin, etc.
I can set a new pin using the pin object created in RealmSwift, but I am having problems checking it.
Here is the RealmSwift part:



import Foundation
import RealmSwift

class pinCode: Object
@objc dynamic var pin = ""


protocol pinCodeManager
func checkForExistingPin() -> Bool
func enterNewPin(newPin:String)
func checkPin(pin:String) -> Bool


class manager:pinCodeManager
let realm = try! Realm()

func checkForExistingPin() -> Bool

let existingCode = realm.objects(pinCode.self)
if existingCode.count == 0
return false

else
return true



func enterNewPin(newPin:String)
if checkForExistingPin()
let oldCode = realm.objects(pinCode.self).first
try! realm.write
oldCode!.pin = newPin


let newPinObject = pinCode()
newPinObject.pin = newPin
realm.add(newPinObject)


func checkPin(pin:String) -> Bool
if checkForExistingPin()
if pin == realm.objects(pinCode.self).first?.pin
return true

else
return false


return false




Here is the ViewController part



import UIKit

class InitialViewController: UIViewController {
var currentPinCode = ""
var pinEntered = ""
var firstPinEntered = ""
var secondPinEntered = ""
let myPin = pinCode()

@IBOutlet weak var enterPinCodeField: UITextField!

@IBAction func GoButton(_ sender: Any)
let enteredPin = enterPinCodeField?.text
if self.myPin.checkPin(pin: enteredPin)
print ("Correct Pin")

else
print ("Incorrect Pin")



@IBAction func NewUserButton(_ sender: Any)
print ("New user selected!")

let pinCodeAlert = UIAlertController(title: "Enter New PIN", message: "", preferredStyle: .alert)
pinCodeAlert.addTextField (configurationHandler:textField1 in

textField1.keyboardType = .numberPad
textField1.placeholder = "Enter new PIN"
textField1.isSecureTextEntry = true
)

let okAction = UIAlertAction(title: "OK", style: .cancel) (action) in
let firstPinEntry = pinCodeAlert.textFields?.first
print ("First PIN entered: " , firstPinEntry!.text)
self.confirmPin(firstPin: firstPinEntry!.text!)


pinCodeAlert.addAction(okAction)
self.present(pinCodeAlert, animated: true, completion: nil)



func confirmPin(firstPin: String)
let pinCodeAlert2 = UIAlertController(title: "Re-enter New PIN", message: "", preferredStyle: .alert)
pinCodeAlert2.addTextField (configurationHandler:textField1 in

textField1.keyboardType = .numberPad
textField1.placeholder = "Re-enter new PIN"
textField1.isSecureTextEntry = true


)
let okAction2 = UIAlertAction(title: "OK", style: .cancel) (action) in
let secondPinEntered = pinCodeAlert2.textFields?.first
print ("2nd PIN entered: " , secondPinEntered?.text! as Any)

if firstPin != secondPinEntered?.text!
print("PINs dont match!")
let pinCodesDontMatch = UIAlertController(title: "PINs don't match!", message: "", preferredStyle: .alert)


let okAction3 = UIAlertAction(title: "OK", style: .cancel) (action) in

pinCodesDontMatch.addAction(okAction3)
self.present(pinCodesDontMatch, animated: true, completion: nil)

else
let newPinSet = UIAlertController(title: "New PIN Set", message: "", preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .cancel) (action) in

newPinSet.addAction(okAction)
self.present(newPinSet, animated: true, completion: nil)
self.myPin.pin = String((secondPinEntered?.text)!)




pinCodeAlert2.addAction(okAction2)
self.present(pinCodeAlert2, animated: true, completion: nil)


@IBOutlet weak var PinCodeField: UITextField!
override func viewDidLoad()
super.viewDidLoad()

// Do any additional setup after loading the view.


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



The line I am having problems with is:



 if self.myPin.checkPin(pin: enteredPin)


I have tried a few variations on it without any success.



The error I get is "Value of type 'pinCode' has no member 'checkPin'"
So I get the impression that it is looking for a member rather than a function called checkPin.



How do I tell it that I'm trying to point it to a function?










share|improve this question


























    0















    I am using RealmSwift to create a pin code object for an iOS app I am building.
    I have created a constructor and a few basic functions to check the pin, enter new pin, etc.
    I can set a new pin using the pin object created in RealmSwift, but I am having problems checking it.
    Here is the RealmSwift part:



    import Foundation
    import RealmSwift

    class pinCode: Object
    @objc dynamic var pin = ""


    protocol pinCodeManager
    func checkForExistingPin() -> Bool
    func enterNewPin(newPin:String)
    func checkPin(pin:String) -> Bool


    class manager:pinCodeManager
    let realm = try! Realm()

    func checkForExistingPin() -> Bool

    let existingCode = realm.objects(pinCode.self)
    if existingCode.count == 0
    return false

    else
    return true



    func enterNewPin(newPin:String)
    if checkForExistingPin()
    let oldCode = realm.objects(pinCode.self).first
    try! realm.write
    oldCode!.pin = newPin


    let newPinObject = pinCode()
    newPinObject.pin = newPin
    realm.add(newPinObject)


    func checkPin(pin:String) -> Bool
    if checkForExistingPin()
    if pin == realm.objects(pinCode.self).first?.pin
    return true

    else
    return false


    return false




    Here is the ViewController part



    import UIKit

    class InitialViewController: UIViewController {
    var currentPinCode = ""
    var pinEntered = ""
    var firstPinEntered = ""
    var secondPinEntered = ""
    let myPin = pinCode()

    @IBOutlet weak var enterPinCodeField: UITextField!

    @IBAction func GoButton(_ sender: Any)
    let enteredPin = enterPinCodeField?.text
    if self.myPin.checkPin(pin: enteredPin)
    print ("Correct Pin")

    else
    print ("Incorrect Pin")



    @IBAction func NewUserButton(_ sender: Any)
    print ("New user selected!")

    let pinCodeAlert = UIAlertController(title: "Enter New PIN", message: "", preferredStyle: .alert)
    pinCodeAlert.addTextField (configurationHandler:textField1 in

    textField1.keyboardType = .numberPad
    textField1.placeholder = "Enter new PIN"
    textField1.isSecureTextEntry = true
    )

    let okAction = UIAlertAction(title: "OK", style: .cancel) (action) in
    let firstPinEntry = pinCodeAlert.textFields?.first
    print ("First PIN entered: " , firstPinEntry!.text)
    self.confirmPin(firstPin: firstPinEntry!.text!)


    pinCodeAlert.addAction(okAction)
    self.present(pinCodeAlert, animated: true, completion: nil)



    func confirmPin(firstPin: String)
    let pinCodeAlert2 = UIAlertController(title: "Re-enter New PIN", message: "", preferredStyle: .alert)
    pinCodeAlert2.addTextField (configurationHandler:textField1 in

    textField1.keyboardType = .numberPad
    textField1.placeholder = "Re-enter new PIN"
    textField1.isSecureTextEntry = true


    )
    let okAction2 = UIAlertAction(title: "OK", style: .cancel) (action) in
    let secondPinEntered = pinCodeAlert2.textFields?.first
    print ("2nd PIN entered: " , secondPinEntered?.text! as Any)

    if firstPin != secondPinEntered?.text!
    print("PINs dont match!")
    let pinCodesDontMatch = UIAlertController(title: "PINs don't match!", message: "", preferredStyle: .alert)


    let okAction3 = UIAlertAction(title: "OK", style: .cancel) (action) in

    pinCodesDontMatch.addAction(okAction3)
    self.present(pinCodesDontMatch, animated: true, completion: nil)

    else
    let newPinSet = UIAlertController(title: "New PIN Set", message: "", preferredStyle: .alert)
    let okAction = UIAlertAction(title: "OK", style: .cancel) (action) in

    newPinSet.addAction(okAction)
    self.present(newPinSet, animated: true, completion: nil)
    self.myPin.pin = String((secondPinEntered?.text)!)




    pinCodeAlert2.addAction(okAction2)
    self.present(pinCodeAlert2, animated: true, completion: nil)


    @IBOutlet weak var PinCodeField: UITextField!
    override func viewDidLoad()
    super.viewDidLoad()

    // Do any additional setup after loading the view.


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



    The line I am having problems with is:



     if self.myPin.checkPin(pin: enteredPin)


    I have tried a few variations on it without any success.



    The error I get is "Value of type 'pinCode' has no member 'checkPin'"
    So I get the impression that it is looking for a member rather than a function called checkPin.



    How do I tell it that I'm trying to point it to a function?










    share|improve this question
























      0












      0








      0








      I am using RealmSwift to create a pin code object for an iOS app I am building.
      I have created a constructor and a few basic functions to check the pin, enter new pin, etc.
      I can set a new pin using the pin object created in RealmSwift, but I am having problems checking it.
      Here is the RealmSwift part:



      import Foundation
      import RealmSwift

      class pinCode: Object
      @objc dynamic var pin = ""


      protocol pinCodeManager
      func checkForExistingPin() -> Bool
      func enterNewPin(newPin:String)
      func checkPin(pin:String) -> Bool


      class manager:pinCodeManager
      let realm = try! Realm()

      func checkForExistingPin() -> Bool

      let existingCode = realm.objects(pinCode.self)
      if existingCode.count == 0
      return false

      else
      return true



      func enterNewPin(newPin:String)
      if checkForExistingPin()
      let oldCode = realm.objects(pinCode.self).first
      try! realm.write
      oldCode!.pin = newPin


      let newPinObject = pinCode()
      newPinObject.pin = newPin
      realm.add(newPinObject)


      func checkPin(pin:String) -> Bool
      if checkForExistingPin()
      if pin == realm.objects(pinCode.self).first?.pin
      return true

      else
      return false


      return false




      Here is the ViewController part



      import UIKit

      class InitialViewController: UIViewController {
      var currentPinCode = ""
      var pinEntered = ""
      var firstPinEntered = ""
      var secondPinEntered = ""
      let myPin = pinCode()

      @IBOutlet weak var enterPinCodeField: UITextField!

      @IBAction func GoButton(_ sender: Any)
      let enteredPin = enterPinCodeField?.text
      if self.myPin.checkPin(pin: enteredPin)
      print ("Correct Pin")

      else
      print ("Incorrect Pin")



      @IBAction func NewUserButton(_ sender: Any)
      print ("New user selected!")

      let pinCodeAlert = UIAlertController(title: "Enter New PIN", message: "", preferredStyle: .alert)
      pinCodeAlert.addTextField (configurationHandler:textField1 in

      textField1.keyboardType = .numberPad
      textField1.placeholder = "Enter new PIN"
      textField1.isSecureTextEntry = true
      )

      let okAction = UIAlertAction(title: "OK", style: .cancel) (action) in
      let firstPinEntry = pinCodeAlert.textFields?.first
      print ("First PIN entered: " , firstPinEntry!.text)
      self.confirmPin(firstPin: firstPinEntry!.text!)


      pinCodeAlert.addAction(okAction)
      self.present(pinCodeAlert, animated: true, completion: nil)



      func confirmPin(firstPin: String)
      let pinCodeAlert2 = UIAlertController(title: "Re-enter New PIN", message: "", preferredStyle: .alert)
      pinCodeAlert2.addTextField (configurationHandler:textField1 in

      textField1.keyboardType = .numberPad
      textField1.placeholder = "Re-enter new PIN"
      textField1.isSecureTextEntry = true


      )
      let okAction2 = UIAlertAction(title: "OK", style: .cancel) (action) in
      let secondPinEntered = pinCodeAlert2.textFields?.first
      print ("2nd PIN entered: " , secondPinEntered?.text! as Any)

      if firstPin != secondPinEntered?.text!
      print("PINs dont match!")
      let pinCodesDontMatch = UIAlertController(title: "PINs don't match!", message: "", preferredStyle: .alert)


      let okAction3 = UIAlertAction(title: "OK", style: .cancel) (action) in

      pinCodesDontMatch.addAction(okAction3)
      self.present(pinCodesDontMatch, animated: true, completion: nil)

      else
      let newPinSet = UIAlertController(title: "New PIN Set", message: "", preferredStyle: .alert)
      let okAction = UIAlertAction(title: "OK", style: .cancel) (action) in

      newPinSet.addAction(okAction)
      self.present(newPinSet, animated: true, completion: nil)
      self.myPin.pin = String((secondPinEntered?.text)!)




      pinCodeAlert2.addAction(okAction2)
      self.present(pinCodeAlert2, animated: true, completion: nil)


      @IBOutlet weak var PinCodeField: UITextField!
      override func viewDidLoad()
      super.viewDidLoad()

      // Do any additional setup after loading the view.


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



      The line I am having problems with is:



       if self.myPin.checkPin(pin: enteredPin)


      I have tried a few variations on it without any success.



      The error I get is "Value of type 'pinCode' has no member 'checkPin'"
      So I get the impression that it is looking for a member rather than a function called checkPin.



      How do I tell it that I'm trying to point it to a function?










      share|improve this question














      I am using RealmSwift to create a pin code object for an iOS app I am building.
      I have created a constructor and a few basic functions to check the pin, enter new pin, etc.
      I can set a new pin using the pin object created in RealmSwift, but I am having problems checking it.
      Here is the RealmSwift part:



      import Foundation
      import RealmSwift

      class pinCode: Object
      @objc dynamic var pin = ""


      protocol pinCodeManager
      func checkForExistingPin() -> Bool
      func enterNewPin(newPin:String)
      func checkPin(pin:String) -> Bool


      class manager:pinCodeManager
      let realm = try! Realm()

      func checkForExistingPin() -> Bool

      let existingCode = realm.objects(pinCode.self)
      if existingCode.count == 0
      return false

      else
      return true



      func enterNewPin(newPin:String)
      if checkForExistingPin()
      let oldCode = realm.objects(pinCode.self).first
      try! realm.write
      oldCode!.pin = newPin


      let newPinObject = pinCode()
      newPinObject.pin = newPin
      realm.add(newPinObject)


      func checkPin(pin:String) -> Bool
      if checkForExistingPin()
      if pin == realm.objects(pinCode.self).first?.pin
      return true

      else
      return false


      return false




      Here is the ViewController part



      import UIKit

      class InitialViewController: UIViewController {
      var currentPinCode = ""
      var pinEntered = ""
      var firstPinEntered = ""
      var secondPinEntered = ""
      let myPin = pinCode()

      @IBOutlet weak var enterPinCodeField: UITextField!

      @IBAction func GoButton(_ sender: Any)
      let enteredPin = enterPinCodeField?.text
      if self.myPin.checkPin(pin: enteredPin)
      print ("Correct Pin")

      else
      print ("Incorrect Pin")



      @IBAction func NewUserButton(_ sender: Any)
      print ("New user selected!")

      let pinCodeAlert = UIAlertController(title: "Enter New PIN", message: "", preferredStyle: .alert)
      pinCodeAlert.addTextField (configurationHandler:textField1 in

      textField1.keyboardType = .numberPad
      textField1.placeholder = "Enter new PIN"
      textField1.isSecureTextEntry = true
      )

      let okAction = UIAlertAction(title: "OK", style: .cancel) (action) in
      let firstPinEntry = pinCodeAlert.textFields?.first
      print ("First PIN entered: " , firstPinEntry!.text)
      self.confirmPin(firstPin: firstPinEntry!.text!)


      pinCodeAlert.addAction(okAction)
      self.present(pinCodeAlert, animated: true, completion: nil)



      func confirmPin(firstPin: String)
      let pinCodeAlert2 = UIAlertController(title: "Re-enter New PIN", message: "", preferredStyle: .alert)
      pinCodeAlert2.addTextField (configurationHandler:textField1 in

      textField1.keyboardType = .numberPad
      textField1.placeholder = "Re-enter new PIN"
      textField1.isSecureTextEntry = true


      )
      let okAction2 = UIAlertAction(title: "OK", style: .cancel) (action) in
      let secondPinEntered = pinCodeAlert2.textFields?.first
      print ("2nd PIN entered: " , secondPinEntered?.text! as Any)

      if firstPin != secondPinEntered?.text!
      print("PINs dont match!")
      let pinCodesDontMatch = UIAlertController(title: "PINs don't match!", message: "", preferredStyle: .alert)


      let okAction3 = UIAlertAction(title: "OK", style: .cancel) (action) in

      pinCodesDontMatch.addAction(okAction3)
      self.present(pinCodesDontMatch, animated: true, completion: nil)

      else
      let newPinSet = UIAlertController(title: "New PIN Set", message: "", preferredStyle: .alert)
      let okAction = UIAlertAction(title: "OK", style: .cancel) (action) in

      newPinSet.addAction(okAction)
      self.present(newPinSet, animated: true, completion: nil)
      self.myPin.pin = String((secondPinEntered?.text)!)




      pinCodeAlert2.addAction(okAction2)
      self.present(pinCodeAlert2, animated: true, completion: nil)


      @IBOutlet weak var PinCodeField: UITextField!
      override func viewDidLoad()
      super.viewDidLoad()

      // Do any additional setup after loading the view.


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



      The line I am having problems with is:



       if self.myPin.checkPin(pin: enteredPin)


      I have tried a few variations on it without any success.



      The error I get is "Value of type 'pinCode' has no member 'checkPin'"
      So I get the impression that it is looking for a member rather than a function called checkPin.



      How do I tell it that I'm trying to point it to a function?







      swift xcode realm






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 1:07









      Ross SatchellRoss Satchell

      11312




      11312






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Your checkPin function has been declared for the pinCodeManager class, but you are trying to call the function for a pinCode object. You need to create a pinCodeManager instance to call checkPin.






          share|improve this answer























          • Thank you. I'm now running into a problem in checkForExistingPin() which has the line let existingCode = realm.objects(pinCode.self) which produces an object, but I'm trying to get the pin associated with that object.

            – Ross Satchell
            Mar 7 at 17:11











          • You should mark this as answered and ask a new question. I'll answer here this time though: realm.objects() will give you ALL pinCode instances. If you're sure you only have one in the realm, you can use .first? to give you an optional result, and dereference that with .pin. i.e. realm.objects(pinCode.self).first?.pin

            – Chris Shaw
            Mar 7 at 20:24










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55034563%2fusing-realmswift-to-create-a-pin-code-trying-to-call-realmswift-function%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Your checkPin function has been declared for the pinCodeManager class, but you are trying to call the function for a pinCode object. You need to create a pinCodeManager instance to call checkPin.






          share|improve this answer























          • Thank you. I'm now running into a problem in checkForExistingPin() which has the line let existingCode = realm.objects(pinCode.self) which produces an object, but I'm trying to get the pin associated with that object.

            – Ross Satchell
            Mar 7 at 17:11











          • You should mark this as answered and ask a new question. I'll answer here this time though: realm.objects() will give you ALL pinCode instances. If you're sure you only have one in the realm, you can use .first? to give you an optional result, and dereference that with .pin. i.e. realm.objects(pinCode.self).first?.pin

            – Chris Shaw
            Mar 7 at 20:24















          1














          Your checkPin function has been declared for the pinCodeManager class, but you are trying to call the function for a pinCode object. You need to create a pinCodeManager instance to call checkPin.






          share|improve this answer























          • Thank you. I'm now running into a problem in checkForExistingPin() which has the line let existingCode = realm.objects(pinCode.self) which produces an object, but I'm trying to get the pin associated with that object.

            – Ross Satchell
            Mar 7 at 17:11











          • You should mark this as answered and ask a new question. I'll answer here this time though: realm.objects() will give you ALL pinCode instances. If you're sure you only have one in the realm, you can use .first? to give you an optional result, and dereference that with .pin. i.e. realm.objects(pinCode.self).first?.pin

            – Chris Shaw
            Mar 7 at 20:24













          1












          1








          1







          Your checkPin function has been declared for the pinCodeManager class, but you are trying to call the function for a pinCode object. You need to create a pinCodeManager instance to call checkPin.






          share|improve this answer













          Your checkPin function has been declared for the pinCodeManager class, but you are trying to call the function for a pinCode object. You need to create a pinCodeManager instance to call checkPin.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 1:22









          Chris ShawChris Shaw

          36838




          36838












          • Thank you. I'm now running into a problem in checkForExistingPin() which has the line let existingCode = realm.objects(pinCode.self) which produces an object, but I'm trying to get the pin associated with that object.

            – Ross Satchell
            Mar 7 at 17:11











          • You should mark this as answered and ask a new question. I'll answer here this time though: realm.objects() will give you ALL pinCode instances. If you're sure you only have one in the realm, you can use .first? to give you an optional result, and dereference that with .pin. i.e. realm.objects(pinCode.self).first?.pin

            – Chris Shaw
            Mar 7 at 20:24

















          • Thank you. I'm now running into a problem in checkForExistingPin() which has the line let existingCode = realm.objects(pinCode.self) which produces an object, but I'm trying to get the pin associated with that object.

            – Ross Satchell
            Mar 7 at 17:11











          • You should mark this as answered and ask a new question. I'll answer here this time though: realm.objects() will give you ALL pinCode instances. If you're sure you only have one in the realm, you can use .first? to give you an optional result, and dereference that with .pin. i.e. realm.objects(pinCode.self).first?.pin

            – Chris Shaw
            Mar 7 at 20:24
















          Thank you. I'm now running into a problem in checkForExistingPin() which has the line let existingCode = realm.objects(pinCode.self) which produces an object, but I'm trying to get the pin associated with that object.

          – Ross Satchell
          Mar 7 at 17:11





          Thank you. I'm now running into a problem in checkForExistingPin() which has the line let existingCode = realm.objects(pinCode.self) which produces an object, but I'm trying to get the pin associated with that object.

          – Ross Satchell
          Mar 7 at 17:11













          You should mark this as answered and ask a new question. I'll answer here this time though: realm.objects() will give you ALL pinCode instances. If you're sure you only have one in the realm, you can use .first? to give you an optional result, and dereference that with .pin. i.e. realm.objects(pinCode.self).first?.pin

          – Chris Shaw
          Mar 7 at 20:24





          You should mark this as answered and ask a new question. I'll answer here this time though: realm.objects() will give you ALL pinCode instances. If you're sure you only have one in the realm, you can use .first? to give you an optional result, and dereference that with .pin. i.e. realm.objects(pinCode.self).first?.pin

          – Chris Shaw
          Mar 7 at 20:24



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55034563%2fusing-realmswift-to-create-a-pin-code-trying-to-call-realmswift-function%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved