Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get images as wel as data from XML file in NSURL as asynchronous download in iphone
    primarykey
    data
    text
    <p>i have an XML file as url where the file contains like this, </p> <pre><code>&lt;Products&gt; &lt;products id="1"&gt; &lt;name&gt;product1&lt;/name&gt; &lt;price&gt;$150&lt;/price&gt; &lt;img&gt;http://www.myimage.com/Main_pic.png&lt;/img&gt; &lt;/products&gt; &lt;/Products&gt; </code></pre> <p>Now using NSXMLParser i can retrieve the data and the image but after i get those data am not understanding how to store in NSMutableArray or NSDictionary. Also i tried to implement lazyloading asynchronous image download from <a href="http://developer.apple.com/library/ios/#samplecode/LazyTableImages/Introduction/Intro.html" rel="nofollow noreferrer">Lazy Loading Table Images Asynchronous Downloading from Apple</a>. But i failed to load the images. Do we have any alternative for aynchronous loading.</p> <p>Kindly describe me in detail about,</p> <ol> <li>how to store a data retieved from url XML file in aysnchronous downloading.</li> <li>how to separate data and image. </li> <li>how to implement those in UIImage and data to view in iPhone. </li> </ol> <p><strong>EDITED</strong></p> <p>for better understanding i need the data and the image like below picture and not in the table view. <img src="https://i.stack.imgur.com/W7DEX.png" alt="Sample Picture"></p> <p><strong>EDITED-2</strong> By using the lazyloading parsing i modified according to my content here the code for your reference,</p> <pre><code>- (void)main{ self.workingArray = [NSMutableArray array]; self.workingPropertyString = [NSMutableString string]; NSXMLParser *parser = [[NSXMLParser alloc] initWithData:dataToParse]; [parser setDelegate:self]; [parser parse]; if (![self isCancelled]){ self.completionHandler(self.workingArray);} self.workingArray = nil; self.workingPropertyString = nil; self.dataToParse = nil;} - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{ if ([elementName isEqualToString:@"Products"]){ self.workingEntry = [[egsLists alloc] init];} storingCharacterData = [elementsToParse containsObject:elementName];} - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{ if (self.workingEntry){ if (storingCharacterData){ NSString *trimmedString = [workingPropertyString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; [workingPropertyString setString:@""]; if ([elementName isEqualToString:sIDStr]){ self.workingEntry.ProductID = trimmedString;} else if ([elementName isEqualToString:sImageStr]){ self.workingEntry.img = trimmedString;}} else if ([elementName isEqualToString:@"Products"]){ [self.workingArray addObject:self.workingEntry]; self.workingEntry = nil;}}} - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{ if (storingCharacterData){ [workingPropertyString appendString:string];}} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload