Exception in List.subscript.getter

Sometime I've got an issue in this function :

func getCurrentEvent(events: RealmSwift.List) -> Event? { let curDate = Date()

let filtered = events.filter { event in
    return (curDate >= event.start) && (curDate <= event.end)
}

if let firstEvent = filtered.first {
    return firstEvent
}

return nil

}

Log:

#0 (null) in __exceptionPreprocess () #1 (null) in objc_exception_throw () #2 (null) in -[NSException raise] () #3 0x10238cf80 in throwRealmException(_:userInfo:) at realm-swift/RealmSwift/Util.swift:53 #4 0x10238cf80 in staticBridgeCast(fromObjectiveC:) at realm-swift/RealmSwift/Util.swift:132 #5 0x10231fdb8 in List.subscript.getter at realm-swift/RealmSwift/List.swift:73 #6 (null) in specialized List.subscript.read () #7 (null) in specialized protocol witness for Collection.subscript.read in conformance List () #8 (null) in specialized LazyFilterSequence<>.startIndex.getter () #9 (null) in specialized protocol witness for Collection.startIndex.getter in conformance <> LazyFilterSequence () #10 (null) in specialized Collection.first.getter () #11 (null) in mainView.getCurrentEvent(events:) ()

How can I secure this function to avoid this ? thanks for your help

It’s hard to say what’s going on here from the (very hard to read) backtrace you posted. Please post a full crash report, per the instructions in Posting a Crash Report.

Having said that, my best guess is that this is very specific to the third-party you’re using and thus you might get more traction by escalating this via its support channel.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Exception in List.subscript.getter
 
 
Q