let myView : MessageView = try! SwiftMessages.viewFromNib(named: "MandateCell") // crash
var config = SwiftMessages.defaultConfig
config.duration = .forever
config.presentationStyle = .bottom
config.dimMode = .gray(interactive: true)
SwiftMessages.show(config: config, view: myView)
this leads to a fatal error. Am I doing something wrong?
You should probably change the MessageView type with your custom type like this:
let myView: MandateCell = try! SwiftMessages.viewFromNib(named: "MandateCell")
If this doesn't fix your issue try catching and printing the error like this:
do {
let myView: MessageView = try SwiftMessages.viewFromNib(named: "MandateCell")
} catch {
print("Error: \(error.localizedDescription)")
}
That way you can investigate the crash further.
You should probably change the
MessageViewtype with your custom type like this:let myView: MandateCell = try! SwiftMessages.viewFromNib(named: "MandateCell")If this doesn't fix your issue try catching and printing the error like this:
do { let myView: MessageView = try SwiftMessages.viewFromNib(named: "MandateCell") } catch { print("Error: \(error.localizedDescription)") }That way you can investigate the crash further.
I tried putting everything in the do try block and i get this for error.localizedDescription : The operation could not be completed (SwiftMessages.SwiftMessagesError error 0)
I created a new class class AddAlternateBank: MessageView { }
Created AddAlternateBank.xib file. selected the File's owner and added the class. Is that the right approach?
My guess is you haven't included your nib file in your app's target. However, it is hard for me to guess are you issue since you didn't post the crash's call stack.
@iamsanketray123 the wrong step is probably this one: "selected the File's owner and added the class"
You shouldn't set your class in the "File's owner" but in the View

That worked @gcharita .Thanks!
Most helpful comment
@iamsanketray123 the wrong step is probably this one: "selected the File's owner and added the class"

You shouldn't set your class in the "File's owner" but in the View