Skip to content

Instantly share code, notes, and snippets.

View mactive's full-sized avatar
🎯
Focusing

mactive mactive

🎯
Focusing
View GitHub Profile
@mactive
mactive / Person.m
Last active July 24, 2016 13:34
JS中调用OC的方法,JSExport JSContext
// in Person.h -----------------
@class Person;
@protocol PersonJSExports <JSExport>
@property (nonatomic, copy) NSString *firstName;
@property (nonatomic, copy) NSString *lastName;
@property NSInteger ageToday;
- (NSString *)getFullName;
-(void)gcdTest1
{
dispatch_queue_t concurrentDispatchQueue=dispatch_queue_create("com.test.queue", DISPATCH_QUEUE_CONCURRENT);
dispatch_async(concurrentDispatchQueue, ^{
NSLog(@"1");
});
dispatch_async(concurrentDispatchQueue, ^{
sleep(2);
NSLog(@"2");
@mactive
mactive / 0_reuse_code.js
Created June 30, 2016 01:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mactive
mactive / 配图.md
Last active June 30, 2016 01:12
Cocoa Static Library,framework,dynamic framework
$(SRCROOT)/projectComponents/RNShare/RNShare
http://lucifer1988.github.io/blog/2015/11/05/ioskai-fa-bei-wang-lu-1/
1.library和framework的比较
library也就是我们常用的.a文件,而framework就是.framework文件,当然还有.dylib这样的文件。
静态库和动态库的区别
静态库:链接时完整地拷贝至可执行文件夹中,被多次使用时会有多份冗余拷贝。
// 文章配图
@mactive
mactive / debugger.html.js
Created June 23, 2016 01:19
debugger.html 文件中的一段js
// file location
// node_module/react-native/local-cli/server/util/debugger.html
function connectToDebuggerProxy() {
var ws = new DebuggerWebSocket('ws://' + window.location.host + '/debugger-proxy');
ws.onopen = function() {
if (sessionID) {
setStatus('Debugger session #' + sessionID + ' active.');
ws.send(JSON.stringify({replyID: parseInt(sessionID, 10)}));
@mactive
mactive / RCTWebSocketExecutor.m
Last active June 23, 2016 01:22
iOS端的注入方法 __fbBatchedBridgeConfig
// file location
// node_module/react-native/Libraries/WebSocket
- (void)executeApplicationScript:(NSData *)script sourceURL:(NSURL *)URL onComplete:(RCTJavaScriptCompleteBlock)onComplete
{
NSDictionary<NSString *, id> *message = @{
@"method": @"executeApplicationScript",
@"url": RCTNullIfNil(URL.absoluteString),
@"inject": _injectedObjects,
};
[self sendMessage:message waitForReply:^(NSError *error, NSDictionary<NSString *, id> *reply) {
// file location:
// node_modules/react-native/local-cli/server/util/debuggerWorker.js
var messageHandlers = {
'executeApplicationScript': function(message, sendReply) {
for (var key in message.inject) {
self[key] = JSON.parse(message.inject[key]);
}
importScripts(message.url);
sendReply();
}
@mactive
mactive / runServer.js
Last active June 23, 2016 07:57
Dive Deep React Native Debugging
// file location
// node_module/react-native/local-cli/server/runServer.js
function runServer(args, config, readyCallback) {
var wsProxy = null;
const packagerServer = getPackagerServer(args, config);
const app = connect()
.use(loadRawBodyMiddleware)
.use(connect.compress())
.use(getDevToolsMiddleware(args, () => wsProxy && wsProxy.isChromeConnected()))
.use(openStackFrameInEditorMiddleware)
debugLog:function (message) {
if (Constants.DEBUG){
if(console){
// 获取调用函数的人 并插在第一个
let callee = arguments.callee.caller.toString();
var mainArguments = Array.prototype.slice.call(arguments);
mainArguments.unshift(callee);
console.log.apply(console, mainArguments);
}