0

Does anyone know how to use SBJson library in swift?

I've this code in Objective-C

NSString *responseString = [request responseString];
NSDictionary *responseDict = [responseString JSONValue];

Trying with

var responseString = request.responseString
let responseDict: NSDictionary = responseString.JSONValue

Xcode complain "() -> String does not have a member named JSONValue"

I've included

#import "SBJson.h"

in "MyProjectName"-Bridging-Header.h

Kevin
  • 16,696
  • 7
  • 51
  • 68

1 Answers1

0

Just found: extension in SBJson apply on NSString type, but Swift String type is a different one.

It works with this code:

var responseString: NSString = request.responseString()
let responseDict: NSDictionary = responseString.JSONValue() as NSDictionary
Kevin
  • 16,696
  • 7
  • 51
  • 68