City-of-Bloomington / open311-ios

GeoReporter iOS source code. Native iOS smartphone client app for Open311 API civic issue reporting.
http://open311.org
Other
23 stars 22 forks source link

Crash when trying to save an empty server #204

Closed inghamn closed 10 years ago

inghamn commented 11 years ago

If you go to the Add Server screen, but do not enter anything, and instead, hit Save. The app crashes:

* Assertion failure in -[AFHTTPClient initWithBaseURL:], /Users/inghamn/Desktop/Projects/open311-mobile/GeoReporter/Pods/AFNetworking/AFNetworking/AFHTTPClient.m:232 2013-10-24 09:27:26.238 GeoReporter[180:907] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: url

zdanovs commented 11 years ago

Ignore first comment, I have fixed and pulled here: https://github.com/City-of-Bloomington/open311-mobile/pull/205

inghamn commented 11 years ago

This does not actually solve the crash problem, though.

zdanovs commented 11 years ago

That's strange. I can't represent it. The onliest case, when app can crash on Add Server screen and cause failure in ../AFHTTPClient.m:232, is passing nil from textFieldUrl while checkingServerValidity in AddServerController.m. So for full confidence it is better to preset all textFields with empty strings in viewDidLoad, but not only in didFinishSaving as I did before. I will make pull request shorty. If it won't help, I will search for another solution.

mariusc commented 11 years ago

I tested and the error only appeared for me on iOS 6. I added an extra "if" to see if the entered URL has a valid format (if the url didn't have a valid format, checkServerValidity: in open311 crashed with error). Now, if the url is invalid, an alert message is shown. I also localized the strings in this alert using google translate.

I meant to send this as a pull request, but I committed it to the master branch by mistake. It's in 89eefc29d75fbddb3ffed681a50a79a4627b7107. For me, this fixes the problem.

zdanovs commented 11 years ago

I added an extra "if" to see if the entered URL has a valid format

This extra "if" confirms my previous guess, that this failure is caused by passing nil. In my opinion, solution with initialising all UITextFields with empty string is more elegant: