Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes when internet connections gets disconnected(Grabbing the NSURL from online) #1

Open
Mattporter0 opened this issue Dec 13, 2015 · 2 comments
Assignees
Labels

Comments

@Mattporter0
Copy link

I am using this animatedImage with a URL from online
let urlString = "URLFROMINTERNET"
let animatedImage = XAnimatedImage(initWithAnimatedGIFData: NSData(contentsOfURL: NSURL(string: urlString!)!)!)

Everything is good, but if I was to put the app into aeroplane mode and scroll though the tableview where the animated image is displayed it will crash with the error
fatal error: unexpectedly found nil while unwrapping an Optional value

Any ideas how to stop this?

@khaledmtaha
Copy link
Owner

Hi Matt,

Theoretically, without replicating the error (which I will get to later) I believe that the optional value should fail gracefully which doesn't seem to be the case currently. I'm certain it will require 'optional chaining' rather than forced unwrapping as mentioned here.

However, as a current workaround let me refer to this Reachability class. This will detect the iPhone connectivity status and could be used to guard against any potential nil values.

Keep in mind that its a suggestion and not foolproof. I offer it in case you are under tight time constraints.

@khaledmtaha khaledmtaha self-assigned this Apr 17, 2016
@khaledmtaha
Copy link
Owner

Does this PR solve the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants