-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmain.mm
More file actions
33 lines (30 loc) · 882 Bytes
/
main.mm
File metadata and controls
33 lines (30 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// main.m
// pythonpythonios
//
// Created by Fancyzero on 13-7-6.
// Copyright (c) 2013年 Fancyzero. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#include "Python.h"
#include <string>
extern "C" void initzlib(void);
int main(int argc, char *argv[])
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"python" ofType:nil inDirectory:@""];
std::string str = [path UTF8String];
str += "/";
char ppp[10240];
strcpy( ppp, str.c_str());
Py_SetPythonHome(ppp);
Py_Initialize();
initzlib();
PyRun_SimpleString("from encodings import ascii");
PyRun_SimpleString("from encodings import hex_codec");
PyRun_SimpleString("import json");
PyRun_SimpleString("import socket");
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}