This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by Vanessa Leung on 2019/2/22. | |
#include <stdio.h> | |
#include <string.h> | |
//Declare all functions to be used first | |
//isLeapYear | |
int leap(int year){ | |
if (((year % 400 == 0) && (year % 3200 != 0)) || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <curl/curl.h> | |
struct MemoryStruct { | |
char *memory; | |
size_t size; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SimpleCloudHandler : MonoBehaviour, ICloudRecoEventHandler | |
{ | |
[System.Runtime.InteropServices.DllImport("__Internal")] | |
//Declare the function you want to call in iOS | |
//e.g. I declare the `unityToIOS` function which I use to pass string to iOS | |
private static extern void unityToIOS (string str); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void OnGUI() { | |
string name = "Vanessa"; | |
//if click the button | |
if (GUI.Button (new Rect (10,10,10,10), "More Details")) { | |
//execute the iOS func | |
unityToIOS (name); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@objc func isDataGet(_ n: NSNotification) { | |
print(n.userInfo?["data"]) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() { | |
super.viewDidLoad() | |
//if receive notification "NotificationName", execute func `isDataGet` | |
NotificationCenter.default.addObserver(self, selector: #selector(isDataGet(_:)), | |
name: NSNotification.Name("NotificationName") , object: nil) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern "C" void unityToIOS(char *str) { | |
//add things you want to pass to iOS here | |
//e.g. I want to pass a string, I save the string in NSDictionary and assign it to userInfo | |
NSString* objcstring = @(str); | |
NSDictionary* dict = @{ @"data": objcstring}; | |
[[NSNotificationCenter defaultCenter] postNotificationName:@"NotificationName" | |
object:nil userInfo:dict]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <curl/curl.h> | |
//struct in C is similar to class | |
struct MemoryStruct { | |
char *memory; | |
size_t size; //size_t is an unsigned integer type of at least 16 bit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(void) | |
{ | |
CURL *curl_handle, curl_handle2; | |
CURLcode res; | |
struct MemoryStruct chunk; | |
//malloc(size of memory blocks in bytes): allocates requested memory and returns pointer to it | |
chunk.memory = malloc(1); /* will be grown as needed by the realloc above */ | |
chunk.size = 0; /* no data at this point */ |
OlderNewer