简体   繁体   中英

iPhone SDK - Problem Parsing XML from RSS feed

I made an RSS reader that gets a feed from blogspot. The text from the story, title, etc. works fine. But the images posted inthe feed show up as links instead of an image. How can I display the images?

Here is some code I use to dynamically download images into a list:

//starts the downloading of the image
- (void) downloadImage
{
    [NSThread detachNewThreadSelector:@selector(imageDownloadWorker:) 
                             toTarget:self 
                           withObject:[self getAvatarUrl]/*here goes your url*/];
}

//does something with the image once loaded
- (void)imageLoaded:(UIImage *)image
{   
    //do something
}

//downloads the image
- (void)imageDownloadWorker:(NSString *)urlString
{
    NSAutoreleasePool *pool  = [[NSAutoreleasePool alloc] init];
    NSURL             *url   = [NSURL URLWithString:urlString];
    NSData            *data  = [NSData dataWithContentsOfURL:url];
    UIImage           *image = [[UIImage alloc] initWithData:data];

    [self performSelectorOnMainThread:@selector(imageLoaded:) 
                           withObject:[image autorelease]
                        waitUntilDone:YES];
    [pool drain];
}

Hope it helps, good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM