title: HTTP Request through JavaScriptCore in iOS7
body: <p>I am trying to use one of iOS7 new features, the JavaScriptCore Framework. I can successfully output a helloWorld string from Javascript, but what I'm interested in, is doing HTTP POSTs in Javascript and then pass the response to Objective-C. Unfortunately, when I'm creating an <code>XMLHttpRequest</code> object in Javascript, I get <code>EXC_BAD_ACCESS (code=1, address=....)</code>. </p>
  
  <p>Here is the Javascript code (<code>hello.js</code>):</p>
  
  <pre><code>var sendSamplePost = function () {
      // when the following line is commented, everything works,
      // if not, I get EXC_BAD_ACCESS (code=1, address=....)
      var xmlHttp = new XMLHttpRequest();
  };
  
  var sayHello = function (name) {
      return "Hello " + name + " from Javascript";
  };
  </code></pre>
  
  <p>Here is the Objective-C code inside my <code>ViewController</code>:</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view, typically from a nib.
  
      JSContext *context = [[JSContext alloc] initWithVirtualMachine:[[JSVirtualMachine alloc] init]];
  
      NSString *scriptPath = [[NSBundle mainBundle] pathForResource:@"hello" ofType:@"js"];
      NSLog(@"scriptPath: %@", scriptPath);
      NSString *script = [NSString stringWithContentsOfFile:scriptPath encoding:NSUTF8StringEncoding error:nil];
      NSLog(@"script: %@", script);
  
      [context evaluateScript:script];
  
      JSValue *sayHelloFunction = context[@"sayHello"];
      JSValue *returnedValue = [sayHelloFunction callWithArguments:@[@"iOS"]];
  
      // this works!
      self.label.text = [returnedValue toString];
  
  
      JSValue *sendSamplePostFunction = context[@"sendSamplePost"];
  
      // this doesn't work :(
      [sendSamplePostFunction callWithArguments:@[]];
  }
  </code></pre>
  
  <p>Could it be that HTTP Requests functionality is not provided in JavaScriptCore Framework? If yes, could I overcome this by using <code>UIWebView</code>'s <code>-stringByEvaluatingJavaScriptFromString:</code>? What if I compiled and included in my project another Javascript Engine (e.g. V8)?</p>