【发布时间】:2011-10-11 04:41:00
【问题描述】:
为了获取URL,我一般都是这样的。
NSString *userText = urlText.text;
NSURL *url = [NSURL URLWithString:userText];
当然,urlText 与 UITextField 相关联。
然而,最近,我在 audioStreaming 程序中看到了这段代码。
(This is the program.)
NSString *escapedValue =
[(NSString *)CFURLCreateStringByAddingPercentEscapes(nil, (CFStringRef)downloadSourceField.text, NULL, NULL,
kCFStringEncodingUTF8) autorelease];
NSURL *url = [NSURL URLWithString:escapedValue];
downloadSourceField 与 UITextField 链接。
这两种方法有什么区别?
当我用 (escapedValue = downloadSourceField.text;) 替换第二种方法 (escapedValue = ~ ~ ) 时,程序运行良好。
你能告诉我有什么区别吗?
流媒体获取 URL 的最佳方法是什么?
【问题讨论】:
标签: iphone objective-c url nsurl