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
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
add a comment |
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
add a comment |
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
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
swift xcode realm
asked Mar 7 at 1:07
Ross SatchellRoss Satchell
11312
11312
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
.
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
.
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
add a comment |
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
.
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
add a comment |
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
.
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
.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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