Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "KochavaUnitySupport.h"
- char* AutonomousStringCopy (const char* string)
- {
- if (string == NULL)
- return NULL;
- char* res = (char*)malloc(strlen(string) + 1);
- strcpy(res, string);
- return res;
- }
- extern "C" {
- char* GetExternalKochavaInfo()
- {
- NSDictionary *kochavaInfo = [[KochavaUnitySupport sharedManager] returnKochavaInfo];
- //Works great for iOS 5
- NSError *error;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:kochavaInfo options:0 error:&error];
- if (! jsonData) {
- NSLog(@"Got an error: %@", error);
- return AutonomousStringCopy("");
- }
- NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- NSLog (@"%@", jsonString);
- const char* jsonChar = AutonomousStringCopy([jsonString UTF8String]);
- return AutonomousStringCopy(jsonChar);
- //Need to loop through the NSDictionary manually and create the JSON object with a string builder
- /*
- for(NSString* key in kochavaInfo)
- {
- NSObject* val = [kochavaInfo objectForKey:key];
- NSLog (@"%@", [key UTF8String]);
- //NSLog (@"%@", [val UTF8String]);
- NSLog (@"-----@");
- }
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement