title: Firebase storage url for tableview image
body: <p>I am migrating across my backend from Parse :'( to Firebase and am having some issues understand Firebase's implementation around assets and referencing them.</p>
  <p>Essentially I need to have a JSON structure detailing some articles, each of these articles will have an image. Currently the JSON is manually added in order for the app to reference the latest articles. The images for this are manually uploaded to the storage aspect of Firebase and the file name of this is added to the JSON of the articles.</p>
  <p>My app calls the <code>JSON</code> in order to populate a table view with a label for the heading of the article and an image in the same cell.</p>
  <p>The problem I am having is retrieving the image URL for the storage assets in order to load the image into the <code>tableview</code>  -</p>
  <p>First I call the data of the article from the database</p>
  <pre><code>  FIRDatabaseReference *ref =  [[FIRDatabase database] reference];
      
      
      [[ref child:@&quot;articles&quot;] observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot * _Nonnull snapshot) {
         
          NSArray *articles = (NSArray *)snapshot.value;} withCancelBlock:^(NSError * _Nonnull error) {
          NSLog(@&quot;%@&quot;, error.localizedDescription);
         
      }];
  </code></pre>
  <p>From the return snapshot is converted into a model object - where the article heading is set to the model object as well as the image URL generated</p>
  <pre><code>Article *article = [Article new];
      article.title = [articleObj valueForKey:@&quot;title&quot;];
      if ([articleObj objectForKey:@&quot;image&quot;] != [NSNull null]) {
  
      // Points to the root reference
      FIRStorageReference *storageRef = [[FIRStorage storage] referenceForURL:@&quot;gs://project-3229518851181635221.appspot.com&quot;];
      // Points to &quot;images&quot;
      FIRStorageReference *imagesRef = [storageRef child:@&quot;articleImages&quot;];
      
      // Note that you can use variables to create child values
      FIRStorageReference *imagePath = [imagesRef child:articleObj[@&quot;image&quot;]];
  
      if (imagePath){
          article.imageURL = [NSURL URLWithString:imagePath.fullPath];
  
      // Fetch the download URL
      [imagePath downloadURLWithCompletion:^(NSURL *URL, NSError *error){
          if (error != nil) {
              // Handle any errors
              NSLog(@&quot;**ERROR %@&quot;, error.description);
              NSLog(@&quot;**ERROR %@&quot;, URL.absoluteString);
              NSLog(@&quot;**ERROR %@&quot;,article.title);
          } else {
              article.imageURL = URL;
  
          }
      }];
      }
      
  </code></pre>
  <p>The problem I have with this method (apart from it feeling like a lot of code for something which feels like it should be a standard property) is that the Article title is available immediately, but the 'downloadURL' block takes longer, so I either need to observe when this finishes and not reload my table until each article has finished obtaining its Image URL</p>
  <p>SO the question:
  Is there an alternative non-blocking way to obtain the image URL
  Or is the URL reference I see in the storage portal for the URL reliable enough to use in my JSON instead of a reference to the image name (so store the URL in my DB rather than the image name)</p>
  <p>Also for reference, I am using SDWebimage for lazyloading images, but the URL is currently not present the first time the <code>tablereloads</code> due to the above-mentioned delays in retrieving the URL</p>
  <p>Thanks in advance!</p>