title: UICollectionView Reload Data
body: <p>After some research I couldn't find an answer to my problem, so let me explain.</p>
  
  <p>The user can create an object that can contain text, audio and image, but he doesn't need to add all three. Later on, it's possible for it to be edited adding an image to it. That part works like a charm. Now, my problem is, I have a collection view to show all the images added and it functions properly if the image is added initially to the object. If the user edits the object adding an image, this new image only shows up when a new object with an image is created.</p>
  
  <p>In resume (tl;dr version) image won't show up if added in edit object mode, it only shows up after new image is added in new object mode. </p>
  
  <p>Here is how the image is fetched in new object mode</p>
  
  <pre><code>NSData *imageData = UIImageJPEGRepresentation(self.image, 0.8f);
      [self.obj setValue:imageData forKey:@"photo"];
  </code></pre>
  
  <p>And also in case it didn't have an image, this happened</p>
  
  <pre><code>self.image = [info objectForKey:UIImagePickerControllerOriginalImage];
      NSData *imageData = UIImageJPEGRepresentation(self.image, 0.8f);
  
      [self.stPhoto setImage:self.image];
      self.obj.photo = imageData;
      [self.obj setValue:imageData forKey:@"photo"];
  </code></pre>
  
  <p>And it is being saved correctly with the context save and all.</p>
  
  <p>Now this is how I get the image from core data to show in edit mode (in case it has one)</p>
  
  <pre><code>self.image = [[UIImage alloc]initWithData:self.obj.photo];
  </code></pre>
  
  <p>No problem here, just to give more information</p>
  
  <p>Now we get to the troublesome parts. This one is where I fetch, call one method I created to loop in a dictionary and reload</p>
  
  <pre><code>NSManagedObjectContext *managedObjectContext = [self managedObjectContext];
  NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"MyObject"];
  [fetchRequest setResultType:NSDictionaryResultType];
  [fetchRequest setPropertiesToFetch:[NSArray arrayWithObjects:@"photo", nil]];
  self.photos = [[managedObjectContext executeFetchRequest:fetchRequest error:nil]mutableCopy];
  
  self.images = [[NSMutableArray alloc] init];
  [self convertDataToImage];
  
  dispatch_async(dispatch_get_main_queue(), ^{
      [self.collectionView reloadData];
  });
  </code></pre>
  
  <p>This is the convertDataToImage method</p>
  
  <pre><code>- (NSMutableArray *)convertDataToImage {
  for (NSDictionary *dictionary in self.photos) {
      NSData *data = dictionary[@"photo"];
      UIImage *image = [[UIImage alloc] initWithData:data];
      CGImageRef cgref = [image CGImage];
      CIImage *cim = [image CIImage];
  
      if (cim == nil &amp;&amp; cgref == NULL) {
          NSLog(@"no underlying data");
      } else {
          [self.images addObject:image];
      }
  }
  if (self.images == nil &amp;&amp; [self.images count] == 0) {
      return self.images;
  } else {
      return 0;
  }
  </code></pre>
  
  <p>I debugged all of it, they all save, fetch, access it all and work just fine, but if the image is added in edit mode it won't show up unless a new image is added via new mode. I hope I explained well my issue and thanks to all of you in advance.</p>