Two properties make an error unique - the domain and the code.
Domains will commonly map to a specific error code enumeration.
For the domain "com.esri.arcgis.runtime.error" which equals `AGSErrorDomain`, the codes you look at are in the enumeration `AGSErrorCode`. Within that enumeration, the code 2 is:
`AGSErrorCodeCommonInvalidArgument = 2`. So you have an Invalid Argument somewhere.
In xcode, set a breakpoint on c++ exceptions. Then when that error occurs you can look at the callstack and see what you may be doing.
I would also make sure to address all the warnings in your project. It may be that you are putting a string in an array that takes a `AGSField` or something like that.
If that doesn't help, please consider providing us some code that reproduces the issue so that we can help diagnose what is going wrong.
Thanks