【问题标题】:xcode thrown error when logging NSURL记录 NSURL 时 xcode 抛出错误
【发布时间】:2013-04-13 23:28:03
【问题描述】:

在使用以下代码运行 xcode 并尝试 nslog url1 时,任何人都可以帮助解决此错误

.m 文件

        NSLog(@"URL flag is not set, Reverting to stored value");
//url1 = [NSURL URLWithString: [NSString stringWithFormat: @"http://radio.qkradio.com.au:8382/listen.mp3"]];
        url1 = [NSURL URLwithString:@"http://radio.qkradio.com.au:8382/listen.mp3"];
        NSLog(url1);

.h 文件

NSURL *url1;

错误

2013-04-14 09:18:41.958 iQkradio[61530:4803] REACHABLE!
2013-04-14 09:18:41.990 iQkradio[61530:c07] Application windows are expected to have a root view controller at the end of application launch
2013-04-14 09:18:42.569 iQkradio[61530:4803] URL flag is not set, Reverting to stored value
2013-04-14 09:18:42.570 iQkradio[61530:4803] +[NSURL URLwithString:]: unrecognized selector sent to class 0x1ef926c
2013-04-14 09:18:42.570 iQkradio[61530:4803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSURL URLwithString:]: unrecognized selector sent to class 0x1ef926c'

【问题讨论】:

    标签: xcode nsurl


    【解决方案1】:

    您的代码中有错字。正确的代码是:

    url1 = [NSURL URLWithString:@"http://radio.qkradio.com.au:8382/listen.mp3"];
    

    请注意,如here 所述,“W”是大写的。希望这会有所帮助!

    【讨论】:

    • 我修好了,但还是有同样的问题
    • 进行此更改后,您仍然收到完全相同的错误吗?
    【解决方案2】:

    正如其他人所提到的,您需要使用URLWithString:

    但还有更多。尝试像这样格式化您的日志NSLog(@"%@",url1);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-25
      • 2010-11-28
      • 1970-01-01
      • 1970-01-01
      • 2017-06-24
      • 2017-10-03
      • 2011-10-29
      • 1970-01-01
      相关资源
      最近更新 更多