Quantcast
Channel: Getting img url from RSS feed swift - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Getting img url from RSS feed swift

$
0
0

I want to be able to retrieve the img url from a piece of string.

Here's a sample of the img URL that I'm trying to retrieve:

<p><img width="357" height="500" src="http://images.sgcafe.net/2015/05/OVA1-357x500.jpg" class="attachment-         medium wp-post-image" alt="OVA1" />

My current implemention is crashing at textCheck which says its NIL. I looked over at the Objective C solution on stackoverflow and implemented it in swift, but it doesn't seem to work.

var elementString = item.summaryvar regex: NSRegularExpression = NSRegularExpression(pattern: "img     src=\"([^\"]*)\"", options: .CaseInsensitive, error: nil)!let range = NSMakeRange(0, count(elementString))var textCheck = regex.firstMatchInString(elementString, options: nil, range: range)!let text = (elementString as NSString).substringWithRange(textCheck.rangeAtIndex(1))

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>