title: ObjC Base64 Decode returns nil
body: <p>I'm trying to decode a Base64 encoded string and it always returns nil when using the UTF8 encoding. I've tried changing the character encoding to several different options and can't get it to return the same value as when I put it into a website like: <a href="https://www.base64decode.org/" rel="nofollow">https://www.base64decode.org/</a></p>
  
  <p>The string I'm trying to decode is "qc6mSDfm1pizbp0szoQmoQ=="</p>
  
  <p>Here is the code I'm using to test this</p>
  
  <pre><code>// DataHelper.m
  
  +(NSString*) base64Encode:(NSString*) string andEncoding:(NSStringEncoding) encoding {
    NSData *plainData = [string dataUsingEncoding:encoding];
    return [plainData base64EncodedStringWithOptions:kNilOptions];
  }
  
  +(NSString*) base64Decode:(NSString*) string andEncoding:(NSStringEncoding) encoding {
    NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:string options:kNilOptions];
    NSString *str = [[NSString alloc] initWithData:decodedData encoding:encoding];
    return str;
  } 
  
  
  // TestCases.m
  -(void) testDecodeEncodeNonce {
    NSString *nonce = @"qc6mSDfm1pizbp0szoQmoQ==";
    NSString *decoded = [DataHelper base64Decode:nonce andEncoding:NSUTF8StringEncoding];
    NSString *encoded = [DataHelper base64Encode:decoded andEncoding:NSUTF8StringEncoding];
    XCTAssertEqualObjects(nonce, encoded);
  }
  </code></pre>