title: base64EncodedStringWithOptions crashing on SenTest
body: <p>I'm having trouble with a function that only seems to crash during my tests inside a SenTestCase object.  </p>
  
  <p>What I'm trying to do is get a base64-Encoded String from an NSData object (that's actually a serialized JSON dictionary). </p>
  
  <p>What actually happens in the code below is the NSJSONSerialization creates an NSConcreteData object which then crashes on <code>[dataFromDictionary base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]</code>  </p>
  
  <p>The crash returned is <code>test failure: -[NSConcreteData base64EncodedStringWithOptions:]: unrecognized selector sent to instance</code>. </p>
  
  <pre><code>(in my SenTestCase implementation)
  -(NSString *)paramsAsString {    
      NSDictionary *storedParams = @{@"stringKeyTest":@"testValueString", @"dictionaryKeyTest":@{@"testDictKey":@"testDictValue"}, @"numberKeyTest":@1 };
      NSError *error = nil;
      BOOL paramCheck = [NSJSONSerialization isValidJSONObject:storedParams]; 
  //paramCheck is true
      NSData *dataFromDictionary = [NSJSONSerialization dataWithJSONObject:storedParams options:0 error:&amp;error]; 
  //dataFromDictionary is actually NSConcreteData
      NSString *stringFromData = [dataFromDictionary base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]; 
  //should stringify NSData, actually crashes
  
      return stringFromData; //never reached
  }
  </code></pre>
  
  <p>I've been googling &amp; stackOverflowing around and there might be a dependency or a header missing from my test target. I just can't understand what that is. Aren't these all Foundation framework functions?</p>
  
  <p>The <code>-all-load</code> and <code>-ObjC</code> flags are also set in the target, the same error occurs.</p>
  
  <p><strong>UPDATE:</strong> 
  In the writing of this post I found the solution to this bug. Keeping the post here for posterity and in case I have found a suboptimal solution.   </p>
  
  <p>Turned out the SenTest was a red herring. What actually was causing the problem was the build target (which was 6.1 in the test simulator, 7.0 on my dev device) not actually having access to the method that was newly made public iOS 7. </p>
  
  <p>I came across this in the documentation for <code>base64EncodedStringWithOptions:</code>:  </p>
  
  <pre><code>Although this method was only introduced publicly for iOS 7, it has existed since iOS 4
  </code></pre>
  
  <p>Since I'm planning on supporting iOS 5 and higher, I added my own implementation of base64 encoding/decoding (based on <a href="https://gist.github.com/Abizern/1643491" rel="nofollow">Matt Gallagher's implementation</a>) and now all is well. </p>
  
  <p>It was simple case of backwards incompatibility. A good lesson to keep in mind for the future. </p>