Detecting a string starting with an expression and case-insensitive

In my iPhone application, I actually detect the text / html content type before displaying the data in a UIWebView or UITextView.

I find this with the variable ContentType, starting with "text / html", the full variable looks like "text / html; charset = utf-8".

So at the moment I am using this:

if (myContentType hasPrefix:@"text/html")

This is beautiful, but case sensitive!

So, when I have the "TEXT / HTML" content type, this does not work.

Is there a way to get the hasPrefix case insensitive method?

Thanks in advance:)

+5
source share
2 answers

, myContentType .

+8

rangeOfString:options::

NSRange range = [myContentType rangeOfString:@"text/html" options: NSCaseInsensitiveSearch| NSAnchoredSearch];
if (range.location != NSNotFound)
     ...
+11

All Articles