liferay / liferay-mobile-sdk

Other
47 stars 56 forks source link

Checking *error #26

Closed twprzybysz closed 8 years ago

twprzybysz commented 8 years ago

During development, I've encountered problem which resulted that application does nothing. After investigation I've discovered that dataWithJSONObject returns error and the valid object. Apple in docs suggest to check returned object, instead of checking error which can be anything. I've discovered couple files where simmilar pattern is used, but this is most valuable place which can be affected by any api call.

https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/ErrorHandling/ErrorHandling.html http://stackoverflow.com/questions/25558442/can-reusing-the-same-nserror-object-be-problematic

wkubiak commented 8 years ago

@brunofarache This caused us some headache back in March and I'm surprised that this bug fix hasn't been pulled into master yet.

jmnavarro commented 8 years ago

Apple doc is pretty clear about this:

When dealing with errors passed by reference, it’s important to test the return value of the method to see whether an error occurred, as shown above. Don’t just test to see whether the error pointer was set to point to an error.

brunofarache commented 8 years ago

Just started reviewing :)

:octocat: Sent from GH.

brunofarache commented 8 years ago

This has been merged, thanks!