Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use a <code>CustomURLConnection</code> with Tag to name de images before they download.</p> <p>With this code you can make a <code>customURLConnection</code>, name it when you make the request, and ask for the name of the image in the <code>connectionDidFinishLoading:</code></p> <h2>CustomURLConnection.h</h2> <pre><code>#import &lt;Foundation/Foundation.h&gt; @interface CustomURLConnection : NSURLConnection { NSString *tag; } @property (nonatomic, retain) NSString *tag; - (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate startImmediately:(BOOL)startImmediately tag:(NSString*)aTag; @end </code></pre> <h2>CustomURLConnection.m</h2> <pre><code>#import "CustomURLConnection.h" @implementation CustomURLConnection @synthesize tag; - (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate startImmediately:(BOOL)startImmediately tag:(NSString*)aTag { self = [super initWithRequest:request delegate:delegate startImmediately:startImmediately]; if (self) { self.tag = aTag; } return self; } - (void)dealloc { [tag release]; [super dealloc]; } @end </code></pre> <p>Then make the connection, a custom url connection in your parsingComplete with:</p> <pre><code>NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:yourURL]; [request setTimeoutInterval:3000.0]; CustomURLConnection *connection = [[CustomURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES tag:imageTag]; </code></pre> <p>Now you can take the <code>imageName</code> with the <code>CustomURLConnection</code> tag, and save it in the <code>connectionDidFinishLoading:</code></p> <pre><code>CustomURLConnection *urlConec = (CustomURLConnection*)connection; NSMutableData *dataFromConnection = [self dataForConnection:urlConec]; </code></pre> <p>and this is the code for the function <code>dataForConnection:</code></p> <pre><code>- (NSMutableData*)dataForConnection:(CustomURLConnection*)connection { NSMutableData *data = [receivedData objectForKey:connection.tag]; return data; } </code></pre> <p>Hope that helps.</p>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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