0

Possible Duplicate:
Load image to a tableView from URL iphone sdk

How can I put the elements of the NSMutableArray in a urls of images?

NSMutableArray is created in the ViewDidLoad function. I am sure, that everything is OK with this array, because I NSLog it and it is fine.

I also tried to something like this

NSString* myString;
myString = [data separatedWithString:@" , "];

and then init the urls of the images with these string.

Thank you in advance!!!

here is the part of the code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *cellID = @"LinkID";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];

        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        }

        NSData *n = [self.data objectAtIndex:indexPath.row];


        NSURL *someUrl = here I have to put the url of the images


        [cell.imageView setImageWithURL:someUrl placeholderImage:[UIImage imageNamed:@"placeholder"]];

        cell.textLabel.text = [n description];

        return cell;

    }
Community
  • 1
  • 1
Costa
  • 3
  • 3
  • possible duplicates - http://stackoverflow.com/questions/7565123/load-image-to-a-tableview-from-url-iphone-sdk http://stackoverflow.com/questions/8390151/loading-images-from-a-url-into-a-uitableviewcells-uiimageview – Vlad Z. Nov 11 '12 at 17:29

1 Answers1

-1

Try this:

NSEnumerator* e = [arrayInstance objectEnumerator];
NSURL *someUrl;
while (someUrl = [e nextObject]) {
   // do your thing here with someUrl
}
hd1
  • 33,938
  • 5
  • 80
  • 91
  • Thank you for the answer! so I did this: NSData *n = [self.data objectAtIndex:indexPath.row]; NSEnumerator *e = [self.data objectEnumerator]; NSURL *someUrl; while (someUrl = [e nextObject]) { [cell.imageView setImageWithURL:someUrl placeholderImage:[UIImage imageNamed:@"placeholder"]]; } cell.textLabel.text = [n description]; But:"2012-11-11 19:50:52.189 parsing[5410:f803] -[__NSCFString absoluteURL]: unrecognized selector sent to instance 0x686ea90" – Costa Nov 11 '12 at 17:53
  • Care to accept the answer, @Costa? – hd1 Nov 11 '12 at 18:02
  • @hd1 The OP needs to load an image from a URL. Your answer has nothing to do with this. A loop isn't needed. The URL needs to be extracted from the array and then used to load an image from the URL. – rmaddy Nov 11 '12 at 18:21
  • Read Costa (OP)'s comment above before you opine, @rmaddy – hd1 Nov 11 '12 at 18:48
  • 1
    He replied to your answer with a bunch of code. This is followed by an error with the code. You then asked him to accept your answer despite his request for further help. So I must ask if you read his comment because he is obviously still having issues. Have a look at the comments to the original question. Those other links actually answer the question. – rmaddy Nov 11 '12 at 18:55