Dou*_*ugh 5 iphone case-insensitive
在我的iPhone应用程序中,我实际上是在UIWebView或UITextView中显示数据之前检测文本/ html内容类型.
我使用以"text/html"开头的ContentType变量检测到这一点,完整变量看起来像"text/html; charset = utf-8".
所以暂时我用这个:
if (myContentType hasPrefix:@"text/html")
Run Code Online (Sandbox Code Playgroud)
这很好,但区分大小写!
因此,当我有"TEXT/HTML"内容类型时,这不起作用.
有没有办法让"hasPrefix"方法不区分大小写?
提前致谢 :)
Vla*_*mir 11
你可以使用rangeOfString:options:功能:
NSRange range = [myContentType rangeOfString:@"text/html" options: NSCaseInsensitiveSearch| NSAnchoredSearch];
if (range.location != NSNotFound)
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1893 次 |
| 最近记录: |