小编Mar*_* D.的帖子

Objective-C NSURL URLWithString在使用变量时似乎失败

所以这是我在StackOverflow上的第一篇文章,请原谅,如果我的请求编写得不好.

我试图使用以下行将类型为NSString的变量加载到NSURL中:

audioPlayer = [[AudioPlayer alloc] initPlayerWithURL:[NSURL URLWithString:aArchiveItem.streamURL] delegate:self];
Run Code Online (Sandbox Code Playgroud)

在我使用的AudioPlayer实现中:

-(id)initPlayerWithURL:(NSURL *)url delegate:(id<AudioPlayerDelegate>) aDelegate {
    self = [super init];

    delegate = aDelegate;

    queue = [[AudioQueue alloc] initQueueWithDelegate:self];

    fileStream = [[AudioFileStream alloc] initFileStreamWithDelegate:self];
    [fileStream open];

    request = [[AudioRequest alloc] initRequestWithURL:url delegate:self];

    return self;
}
Run Code Online (Sandbox Code Playgroud)

当我硬编码URL字符串(如URLWithString:@" http://www.example.com ")的调用audioPlayer工作完美,但试图与aArchiveItem.streamURL的失败值来填充它的时候...

我在这做错了什么?

iphone cocoa cocoa-touch objective-c

2
推荐指数
1
解决办法
2533
查看次数

标签 统计

cocoa ×1

cocoa-touch ×1

iphone ×1

objective-c ×1