0

I'm trying to pull down some XML from api.StackExchange. I've tried several things in Xcode playgrounds, but this is my latest attempt, in it's entirety:

import UIKit
import Foundation

var error: NSError?

var apiXML = NSString(
    contentsOfURL: NSURL(string: "api.stackexchange.com/answers?site=stackoverflow"), 
    encoding: NSUTF8StringEncoding, 
    error: &error)

That last line is getting the error: Execution was interrupted, reason: EXC_BREAKPOINT (code=EXC_1386_BPT, subcode=0x0)

Frankly, I have no idea what this error means and I would really appreciate somebody helping me here.

PopKernel
  • 4,110
  • 5
  • 29
  • 51

1 Answers1

0

This is not a valid URL:

"api.stackexchange.com/answers?site=stackoverflow"

If you change it to:

"http://api.stackexchange.com/answers?site=stackoverflow"

The code you posted works perfectly.

Abhi Beckert
  • 32,787
  • 12
  • 83
  • 110