title: Converting Swift to Objective-C explanation of compiler warning?
body: <p>I want to create a wrapper around the NSURLSession and I found some nice code but was written in Swift.<a href="https://github.com/daltoniam/SwiftHTTP.But" rel="nofollow">https://github.com/daltoniam/SwiftHTTP.But</a> since I still write production code in Objective-C I started borrowing the idea of the above code, though I have hard time to understand the following code and translate to Objective-C (if needed). 
  I know I could use AFNetworking but this is not feasible due to architecture decisions when building a distributable framework.</p>
  
  <p>The code:</p>
  
  <pre><code>    /// encoding for the request.
      public var stringEncoding: UInt = NSUTF8StringEncoding
  
  // Somewhere in a method
  
      var charset = CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(self.stringEncoding));
  if request.valueForHTTPHeaderField(contentTypeKey) == nil {
                      request.setValue("application/x-www-form-urlencoded; charset=\(charset)",
                          forHTTPHeaderField:contentTypeKey)
                  }
                  request.HTTPBody = queryString.dataUsingEncoding(self.stringEncoding)
  </code></pre>
  
  <p>My Objective-C code:</p>
  
  <pre><code>@property (assign, nonatomic) NSUInteger stringEncoding;
  
      // In this line I get a compiler warning and in runtime it crashes with BAD_EXC
          CFStringEncoding cfStringEncoding = CFStringConvertIANACharSetNameToEncoding(CFStringConvertNSStringEncodingToEncoding(self.stringEncoding));
                  if (![mutableRequest valueForHTTPHeaderField:ContentTypeKey])
                      {
                      [mutableRequest setValue:[NSString stringWithFormat:@"application/x-www-form-urlencoded; charset=%u", (unsigned int)cfStringEncoding] forHTTPHeaderField:ContentTypeKey];
                      }
                  mutableRequest.HTTPBody = [queryString dataUsingEncoding:self.stringEncoding];
  </code></pre>
  
  <p>Compiler warning:</p>
  
  <pre><code>Incompatible integer to pointer conversion assigning to 'CFStringEncoding' (aka 'unsigned long') from 'CFStringRef' (aka 'const struct __CFString *')
  </code></pre>
  
  <p>I don't have strong experience working with CFStringEncoding and CFString so I find it hard to translate the documentation. </p>
  
  <p>Do I really need this conversion, and what is it's purpose?</p>