objective c - When I get a JSON object from PHP on iOS, I get the NULL value -
Edit first:
I put return data in JSONObjectWithData: option: error but error persists is.
The problem is 1 in 10 times, but it is upset because the application does not work.
2014-02-18 10: 26: 03.236 Final Abogados [47279: f803] Error En consulta basica: Error domain = NSCocoaErrorDomain code = 3840 "Operation could not be completed. (Cocoa error 3840.) "(JSON did not start with the option to set the array or object and not set pieces.) UserInfo = 0x686c330 {NSDebugDescription = JSON did not start with the text array or the option to set the objects and pieces .}
An API is doing an APOP that is a PHP script which allows JSON Object PV The appropriate.
The script calls data from the data base in MS SQL and encodes these data in the JSON object. Then I get the object on iOS and I use NSJSONSerialize to handle the data.
The problem is, sometimes I get a zero value and sometimes I get the array correctly, the data is always the same as the script back to me, show here: "Judicial", "Judicial", "2": "(Season Asinger)"; "Judicial"; "Judicial"; "Judicial"; "Judicial"; "2" The code that queries and queries the query is:
NSString * myRequestString = ["]", "Nmerro": "(Sens Asigner)"]]
NSString stringWithFormat: @ "user =% @ and pass =% @ and cod_asunto =% @", then _Resived, p_received, cod_received] NSDTa * myRequestData = [NSDTATA DataWithBites: [myRequestString UTF8String] Length: [myRequestString length]]; NSMutableURLRequest * request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: @ ""]] [set] Http System: @ "Post"] [Request Set Value: http "Headerfield for App / X-www-Form-URLXode": @ "Content-Type"]; [Set HTTPBD: myRequestData]; NSURLResponse * Response; NSError * Error; NSDTA * ReturnData = [Synchronous request sending NSRR connection: Returning Response: And Response Error: And Edition]; NSString * content = [NSString string withUTF8 string: [return data byte]]; NSDTA * jsondata = [Content Data Device Encoding: NSUTF8StringEncoding]; NSError * jsonError = Zero; ID jsonObject = [NSJSONAsolution JSONObjectWithData: Jessondata Options: Cancellation Option Error: & amp; Jason Errre]; NSMutableArray * NombreOrga = [[NSMutableArray alloc] init]; NSMutableArray * NombreInstancia = [[NSMutableArray alloc] init]; NSMutableArray * Numero = [[NSMUTABARARROL] INST]; If ([jsonObject isKindOfClass: [NSArray class]]) {NSLog (@ "its ARRA !!."); NSArray * jsonArray = (NSArray *) jsonObject; (For id items in JSNRAA) {if ([item hackedAfcla: [NSTOE class]]) {NSString * aux = [(NSDictionary *) Item Objectwork: @ "NobberOrgismo"]; NSString * aux2 = [(NSDictionary *) Object object ForKey: @ "Numero"]; NSString * aux3 = [(NSDictionary *) Object object forKey: @ "NombreTipoInstancia"]; If (aux) {[nimbroorda ad object: aux]; } If (aux2) {[nombreinstania adobect: aux2]; } If (aux3) {[Numero adobject: aux3]; }} And {NSLog (@ "item% @ is not a dictionary", item); }}} And {nslog (@ "this is probably an advocate!"); }
This is very strange, sometimes NSLog tells me " Its probably a preference! " and the value is empty and the app does not work. And sometimes NSLog tells me " its ARRE! " and this application works correctly.
But the statistics returned by SCRIPT are always the same!
Thank you very much for your help.
Comments
Post a Comment