- Where Developers Learn, Share, & Build Careers
I have an app that has just opened up a webserver page which gives me a Jason string when I am all over the local network Working without problems, but when I open the application outside of the local network and how can I control the json string without crashing the VPN app? This is my code:
NSString * urlstr = [[NSString alloc] initWithFormat: @ "% @ yes.php", AV]; NSDRL * URL = [[NSROLLOOL] InitWestString: URLState]; NSError * Error = Zero; NSString * urlString = [NSString stringWithContentsOfURL: url encoding: NSASCIIStringEncoding Error: & amp; Error]; NSString * newStr; NSDT * Data = [New STR Data Using Encoding: NSUTF 8 String Encoding]; NSDictionary * json = [NSJSNSArulization JSONObjectWithData: Data Option: kNilOptions Error: & amp; Error]; Sn1 = [[Jason ObjectForcae: @ "Riley 1"] interview]; I want to compare the json answer with a zero value, if two criteria are identical I will show a warning.
Edit: If I try to read any value, the app crashes, the JSN response is waiting ... with a timeout interface parameter with an NSURLRequest The problem is ignored, which closes the connection after n seconds.
In addition to other things, you failed to do this:
- Check if an attempt to fetch ASCII-encoded string from a remote URL failed (obvious possibilities: the URL is not inaccessible, the result is UTF-8 instead of ASCII);
- Check if JSON parsing is successful (obvious possibility: return server 404D and instead of returning an HTML error page)
- Check whether the returned JSON object is actually a dictionary ( For example, this can be an array, in which case an exception will be raised on
objectForKey: ) Parsing of return data as ASCII again again encodin Living in UTF-8 is also probably redundant ??? Because it suppresses each other, it has the effect of a threshold test, otherwise preventing the action from accepting action.
Comments
Post a Comment