fork download
  1. #import <objc/objc.h>
  2. #import <objc/Object.h>
  3.  
  4. @implementation TestObj
  5. int main()
  6. {
  7. NSError *error;
  8. NSURL *url = [NSURL URLWithString:urlString];
  9. NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
  10. [request setHTTPMethod:@"GET"];
  11. [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
  12.  
  13. NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse: nil error:&error];
  14. if (!data)
  15. {
  16. NSLog(@"Download Error: %@", error.localizedDescription);
  17. UIAlertView *alert =
  18. [[UIAlertView alloc]initWithTitle:@"Error"
  19. message:[NSString stringWithFormat:@"Error : %@",error.localizedDescription]
  20. delegate:self
  21. cancelButtonTitle:@"Ok"
  22. otherButtonTitles:nil];
  23. [alert show];
  24. return nil;
  25. }
  26.  
  27. // Parsing the JSON data received from web service into an NSDictionary object
  28. NSDictionary *JSON =
  29. [NSJSONSerialization JSONObjectWithData: data
  30. options: NSJSONReadingMutableContainers
  31. error: &error];
  32. return JSON;
  33. // your code goes here
  34. return 0;
  35. }
  36. @end
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.m:5:1: warning: cannot find interface declaration for 'TestObj' [enabled by default]
prog.m: In function 'main':
prog.m:7:2: error: unknown type name 'NSError'
prog.m:8:5: error: unknown type name 'NSURL'
prog.m:8:19: error: 'NSURL' undeclared (first use in this function)
prog.m:8:19: note: each undeclared identifier is reported only once for each function it appears in
prog.m:8:39: error: 'urlString' undeclared (first use in this function)
prog.m:9:5: error: unknown type name 'NSMutableURLRequest'
prog.m:9:37: error: 'NSMutableURLRequest' undeclared (first use in this function)
prog.m:10:5: error: cannot find interface declaration for 'NSConstantString'
prog.m:10:5: warning: invalid receiver type 'int *' [enabled by default]
prog.m:10:5: warning: no '-setHTTPMethod:' method found [enabled by default]
prog.m:10:5: warning: (Messages without a matching method signature [enabled by default]
prog.m:10:5: warning: will be assumed to return 'id' and accept [enabled by default]
prog.m:10:5: warning: '...' as arguments.) [enabled by default]
prog.m:11:5: warning: invalid receiver type 'int *' [enabled by default]
prog.m:11:5: warning: no '-setValue:forHTTPHeaderField:' method found [enabled by default]
prog.m:13:5: error: unknown type name 'NSData'
prog.m:13:21: error: 'NSURLConnection' undeclared (first use in this function)
prog.m:16:9: warning: implicit declaration of function 'NSLog' [-Wimplicit-function-declaration]
prog.m:16:43: error: request for member 'localizedDescription' in something not a structure or union
prog.m:17:9: error: unknown type name 'UIAlertView'
prog.m:18:11: error: 'UIAlertView' undeclared (first use in this function)
prog.m:19:44: error: 'NSString' undeclared (first use in this function)
prog.m:19:89: error: request for member 'localizedDescription' in something not a structure or union
prog.m:20:43: error: 'self' undeclared (first use in this function)
prog.m:23:9: warning: invalid receiver type 'int *' [enabled by default]
prog.m:23:9: warning: no '-show' method found [enabled by default]
prog.m:24:9: warning: return makes integer from pointer without a cast [enabled by default]
prog.m:28:5: error: unknown type name 'NSDictionary'
prog.m:29:6: error: 'NSJSONSerialization' undeclared (first use in this function)
prog.m:30:46: error: 'NSJSONReadingMutableContainers' undeclared (first use in this function)
prog.m:32:5: warning: return makes integer from pointer without a cast [enabled by default]
stdout
Standard output is empty