SWBufferedToast
SWBufferedToast copied to clipboard
Crashing in a Swift App
Hi
I am using the logintoast inside a swift app. Here is my implementation:
Delegate:
class ViewController: UIViewController, SWBufferedToastDelegate {
...
}
Action to present and declare the toast:
@IBAction func loginAction(sender: AnyObject) {
let toast = SWBufferedToast(loginToastWithTitle: "Login", usernameTitle: "Email", passwordTitle: "Password", doneTitle: "Login", backgroundColour: FlatGreen(), toastColor: UIColor.flatGreenColorDark(), animationImageNames: nil, andDelegate: self, onView: self.view)
toast.appear()
}
Finally here are my delegate methods inside the same view controller:
// SWBufferedToast Delegate methods
func didAttemptLoginWithUsername(username: String!, andPassword password: String!, withToast toast: SWBufferedToast!) {
toast.beginLoading()
}
func didTapActionButtonWithToast(toast: SWBufferedToast!) {
print("button tapped")
}
func didDismissToastView(toast: SWBufferedToast!) {
print("dismissed")
}
The App crashes as soon as I hit the login button and call toast.beginLoading(). The stack trace of the crash is:
Dec 2 14:24:13 FlashFitPro[23654] <Error>: CGContextFillRects: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
2015-12-02 14:24:13.286 FlashFitPro[23654:164843] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c5ccf45 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010bcbedeb objc_exception_throw + 48
2 CoreFoundation 0x000000010c493ea5 -[__NSArrayM insertObject:atIndex:] + 901
3 SWBufferedToast 0x0000000109fcf5af -[SWToast bufferImage] + 783
4 SWBufferedToast 0x0000000109fd0bb8 -[SWToast showBufferAnimation] + 104
5 SWBufferedToast 0x0000000109fcf9ce -[SWToast showBuffer] + 286
6 SWBufferedToast 0x0000000109fcc1a6 -[SWBufferedToast beginLoading] + 70
7 FlashFitPro 0x000000010952e78e _TFC11FlashFitPro14ViewController27didAttemptLoginWithUsernamefS0_FTGSQSS_11andPasswordGSQSS_9withToastGSQCSo15SWBufferedToast__T_ + 254
8 FlashFitPro 0x000000010952e9a5 _TToFC11FlashFitPro14ViewController27didAttemptLoginWithUsernamefS0_FTGSQSS_11andPasswordGSQSS_9withToastGSQCSo15SWBufferedToast__T_ + 453
9 SWBufferedToast 0x0000000109fcd370 -[SWBufferedToast loginButtonTappedWithUsername:andPassword:] + 128
10 SWBufferedToast 0x0000000109fcfcf2 -[SWToast performLoginAction] + 210
11 SWBufferedToast 0x0000000109fcfba0 -[SWToast didTapActionButton:] + 144
12 UIKit 0x000000010a340e91 -[UIApplication sendAction:to:from:forEvent:] + 92
13 UIKit 0x000000010a4ac4d8 -[UIControl sendAction:to:forEvent:] + 67
14 UIKit 0x000000010a4ac7a4 -[UIControl _sendActionsForEvents:withEvent:] + 311
15 UIKit 0x000000010a4ab8d4 -[UIControl touchesEnded:withEvent:] + 601
16 UIKit 0x000000010a3aeed1 -[UIWindow _sendTouchesForEvent:] + 835
17 UIKit 0x000000010a3afc06 -[UIWindow sendEvent:] + 865
18 UIKit 0x000000010a35f2fa -[UIApplication sendEvent:] + 263
19 UIKit 0x000000010a339abf _UIApplicationHandleEventQueue + 6844
20 CoreFoundation 0x000000010c4f9011 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
21 CoreFoundation 0x000000010c4eef3c __CFRunLoopDoSources0 + 556
22 CoreFoundation 0x000000010c4ee3f3 __CFRunLoopRun + 867
23 CoreFoundation 0x000000010c4ede08 CFRunLoopRunSpecific + 488
24 GraphicsServices 0x000000010fe28ad2 GSEventRunModal + 161
25 UIKit 0x000000010a33f30d UIApplicationMain + 171
26 FlashFitPro 0x000000010953778d main + 109
27 libdyld.dylib 0x000000010d28c92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Can you please help?
Have you found any solution?