0

I'm trying to make an app which displays the images posted on a website, but the site uploads a couple of images every month, and I want the app to immediately display the new images as soon as they are uploaded on the website.

The website is : http://www.bowtieful.com/bowtiecollection/

How do I get the images from the website into my app?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Romano Vacca
  • 305
  • 1
  • 4
  • 11
  • Are you sure the terms of the site allow you to do that? – woz Jul 22 '13 at 19:11
  • http://stackoverflow.com/questions/6238139/ios-download-and-save-image-inside-app – Marcus Adams Jul 22 '13 at 19:24
  • @MarcusAdams i took a quick lookk and it looks like the link you gave me, uses a url of one image to display the image, but i want to use the url of the website so it displays all the images on the page. – Romano Vacca Jul 22 '13 at 19:30

3 Answers3

0

Assuming the image URLs are not consistent from month to month I would use TFHpple and when the app loads, parse the DOM searching for @"//img" and pull the src URL attribute from the results.

This Tutorial is fantastic for TFHpple.

Dan
  • 5,153
  • 4
  • 31
  • 42
  • i read and tried the tutorial you gave me, i understand parsing html a lot better now! but now i am struggling to display the image in the row, not the title and link like in the raywenderlich tutorial. So far i got this : [IMG]http://i39.tinypic.com/2hels06.png[/IMG] And this is my .m [IMG]http://i44.tinypic.com/syb6tz.png[/IMG] – Romano Vacca Jul 23 '13 at 18:00
  • Romano - I'm afraid I'm not following your question & problem. Are those two values that TFHpple is returning to you? – Dan Jul 23 '13 at 19:21
  • i used the raywenderlich tutorial as a starterpoint. But in that tutorial they only show you how to use the parsed data to set the tableviews title and description. But i want to have a individual imageview on every row. Somthing like this [IMG]http://i41.tinypic.com/15cggmg.png[/IMG] , except they are all the same. I now how to get the url of all the images by parsing the website, but i dont know how to let the row display these url's as an image. I want to know this because later on i want to make a custumized cell for each row. And also thanks for your help so far! – Romano Vacca Jul 24 '13 at 10:29
  • class="hasimg" href="http://www.bowtieful.com/houndstooth-bowtie/"> This is the source code of the site and i need the tableview to display the SRC as an image of a row for each row – Romano Vacca Jul 24 '13 at 10:30
  • my response is above,, i answered my own question – Romano Vacca Jul 24 '13 at 16:12
0

You need something like this to parse the HTML of the page:

https://github.com/zootreeves/Objective-C-HMTL-Parser

It looks like you might be able to just grab every <img> element, so it would look like this:

HTMLParser *parser = [[HTMLParser alloc] initWithString:html error:&error];

if (error) {
    NSLog(@"Error: %@", error);
    return;
}

HTMLNode *bodyNode = [parser body];

NSArray *imgNodes = [bodyNode findChildTags:@"img"];

for (HTMLNode *imgNode in imgNodes) {
    NSData *imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: [inputNode getAttributeNamed:@"src"]]];
    UIImage *img = [UIImage imageWithData:imageData]; // do whatever you need to with this
}
woz
  • 10,888
  • 3
  • 34
  • 64
0

D80Buckeye

This is how i declare my properties in BowtiefulImages.h.

import

@interface BowtiefulImages : NSObject

@property (nonatomic, copy) NSString *title; @property (nonatomic, copy) NSString *url;

@end

This is my MasterviewController.M http://i41.tinypic.com/72d85z.png

And this is also in my MasterviewController.m http://i41.tinypic.com/k9c3z4.png

If i do what you last suggested i still dont get the uiimages on every row. On the last 2 lines ( the lines that you suggested) i've put // before it because xcode gives an error : use of undeclared identifier url.

Romano Vacca
  • 305
  • 1
  • 4
  • 11
  • In all fairness you have a second issue which should probably be a second and separate question. Your original question has been solved, now you have an secondary implementation problem using your original solution. – Dan Jul 24 '13 at 17:47
  • okay, then i will open another topic for the question. But you've helped me a lot, thanks !! – Romano Vacca Jul 24 '13 at 17:53