title: Encoded string from UIImage return null
body: <p>I used this answer to convert a UIImage in a NSSstring, </p>
  
  <p><a href="https://stackoverflow.com/a/11251478/3741799">https://stackoverflow.com/a/11251478/3741799</a></p>
  
  <p>to encode</p>
  
  <pre><code>- (NSString *)encodeToBase64String:(UIImage *)image {
   return [UIImagePNGRepresentation(image) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
  }
  </code></pre>
  
  <p>to decode</p>
  
  <pre><code>- (UIImage *)decodeBase64ToImage:(NSString *)strEncodeData {
    NSData *data = [[NSData alloc]initWithBase64EncodedString:strEncodeData options:NSDataBase64DecodingIgnoreUnknownCharacters];
    return [UIImage imageWithData:data];
  }
  </code></pre>
  
  <p>here encode the image and put the NSString in an NSObject class</p>
  
  <pre><code> self.newData.imageString = [self encodeToBase64String: image];
  </code></pre>
  
  <p>add the new object to the tableView </p>
  
  <pre><code>- (Void) insertNewObject: (id) sender {
      
       if (! self.objects) {
     
           [self.objects addObject: self.newData.imageString]; 
        
           [self.tableView reloadData]; 
       } 
    
  
       [self.objects InsertObject: self.newData atIndex: 0]; 
       NSIndexPath * indexPath = [NSIndexPath indexPathForRow: 0 inSection: 0]; 
       [self.tableView insertRowsAtIndexPaths: @ [indexPath] withRowAnimation: UITableViewRowAnimationAutomatic]; 
      
  
  } 
  </code></pre>
  
  <p>then load the new object in the TableView! </p>
  
  <pre><code>- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {
  
       static NSString * CellIdentifier = @ "Custom"; 
       CustomCell * cell = (CustomCell *) [self.tableView dequeueReusableCellWithIdentifier: CellIdentifier forIndexPath: indexPath]; 
       ObjectClass * object = [self.objects objectAtIndex: indexPath.row]; 
    
           cell.imageView.image = [self decodeBase64ToImage: object.imageString]; 
  
       return cell; 
  } 
  </code></pre>
  
  <p>But when I load the image in the cell can not decode the string because it has a null value, and the app crash! </p>
  
  <blockquote>
    <p><strong>* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*</strong> -[_NSPlaceholderData
    initWithBase64EncodedString:options:]: nil string argument'</p>
  </blockquote>
  
  <p>I think that the problem is in the encoding but I can't solve it by myself! </p>
  
  <p>Where am I wrong? </p>
  
  <p>thanks</p>
  
  <blockquote>
    <p>QUESTION UPDATE</p>
  </blockquote>
  
  <p>The Zaph question is right, I try to explain better: 
  I have an empty table view, the user adds an image and a text string for each row. 
  So I tried to use this guide official Apple </p>
  
  <p><a href="https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/ThirdTutorial.html" rel="nofollow noreferrer">https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/ThirdTutorial.html</a></p>
  
  <p>In the class XYZToDoItem add the property  @property NSString * itemName; and I can easily add the text string created by user. 
  But how can I add the images in this class? 
  So I thought to convert images into strings and add a property @property NSString * imageString; 
  But something wrong and I can't do that ! 
  Can you suggest a better way to do this?</p>
  
  <p>Thank you so much for your support and help !!</p>