Reputation: 13
I have a swift project. App is crashing when I tap on button.
func shareRide() {
if let currentLocation = currentLocation.value {
let format = "http://maps.google.com/maps?q=loc:\(currentLocation.latitude),\
(currentLocation.longitude)"
let message = "\(AppName) :- \(String.removeNil(User.main.firstName)) \.
(String.removeNil(User.main.lastName)) \.
(Constants.string.wouldLikeToShare) \(format)"
self.share(items: [#imageLiteral(resourceName: "Splash_icon"), message]) *Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1cd595b2c)*
}
}
func share(items : [Any]) {
let activityController = UIActivityViewController(activityItems: items, applicationActivities: nil)
activityController.excludedActivityTypes = [.airDrop]
if let popoverController = activityController.popoverPresentationController {
popoverController.sourceRect = CGRect(x: UIScreen.main.bounds.width / 2, y: UIScreen.main.bounds.height / 2, width: 0, height: 0)
popoverController.sourceView = self.view
popoverController.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
}
self.present(activityController, animated: true, completion: nil)
}
shareRide() is the method that calling when tap the button.
This is a screenshot of my current bug
Thanks, Looking forward for your answers!
Upvotes: 1
Views: 5018
Reputation: 1684
If you're sure that format
and message
are not nil
, then your image literal (Splash_icon) is probably nil
.
Try removing it temporarily to verify this.
Upvotes: 1