NSCocoaErrorDomain Code=256

前端 未结 7 941
太阳男子
太阳男子 2020-12-01 20:59

I have been stuck with this for a while and don\'t seem to get around this.

I am trying to read the contents of an URL as a string from an URL, But i get a weird

7条回答
  •  独厮守ぢ
    2020-12-01 21:18

    Yes, the URL is missing the scheme: "http://".

    "Error -> Error Domain=NSCocoaErrorDomain Code=256"

    For the error code check the Apple documentation:

    NSError codes in the Cocoa error domain.

    NSFileReadUnknownError = 256,
    

    NSFileReadUnknownError
    "Read error, reason unknown"

    Not that the error definition is very helpful. :-)

    Also do not check if error is nil to determine if there is an error, check the return value for nil. error is not guaranteed to be nil on successful execution.

提交回复
热议问题