Closed webmagnets closed 9 years ago
This is normal Swift behavior (though arguably a language bug) and unrelated to Realm. You should read the section on Optional Binding of the Swift Programming Language Guide, if you haven't already.
Basically, .firstObject() as? Word
fails because you're doing an optional cast rather than casting to an optional (.firstObject() as Word?
). So I think your if statement should actually be if var word = Word.objectsWhere("simplified = '〇'").firstObject() as Word?
. Note that I'm not specifying the type in word: Word
because it's already specified as Word
from optionally binding from Word?
, so it's redundant.
Please reopen this issue if this is still causing you issues after making my suggested changes.
The real problem was I had "\r" at the end of the string in Word.simplified. Thanks for helping me rule the other stuff out.
if var word: Word = Word.objectsWhere("simplified = '〇'").firstObject() as? Word
Why is this returning false when, as you can see in the attached image, there is an object with 〇 in the simplified column?