1

I am trying output my json from RestKit to the console. I read that

RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelDebug);

is the way to do it. However, it seems swift isn't happy with that. I came across this blog http://blog.markhorgan.com/?p=824 and it says I need to add an Obj-c implementation file, which I did. Now, I'm not very good at obj-c and the supporting libraries, so I put the obj-c file in the same folder where my bridging header file is at, if that's even right? I tried to import the new obj-c file to the bridge header file, but no avail for my swift file. How do I call this RKLog method in my swift file? Thanks in advance.

Wain
  • 118,658
  • 15
  • 128
  • 151
JordanA.
  • 11
  • 2

1 Answers1

0

Create a new CocoaClass, call it RKObjC then RKObjC.h will be like this:

#import <Foundation/Foundation.h>

@interface RKObjC : NSObject 

+(void)initLogging;

@end

and RKOBjC.m :

#import "RKObjC.h"
#import "RestKit/RestKit.h"

@implementation RKObjC

+ (void) initLogging{
    #ifdef DEBUG
        RKLogConfigureByName("RestKit", RKLogLevelTrace);
        RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelInfo);
        RKLogConfigureByName("RestKit/Network", RKLogLevelTrace);
        RKLogConfigureByName("RestKit/CoreDate", RKLogLevelTrace);
    #endif
}

@end

Then in your Swift file just call initLogging:

RKObjC.initLogging() 

Of course you have to import RKObjc.h in your Bridging-Header