xcodeswiftsbjson

SBJson and swift


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


Solution

  • 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