- Create a project in XCode with the default settings
- iOS > Application > Single View Application
- Language: Swift
- Under project General settings, add ReactKit to Linked Framework and Libraries
- + > Add Other... and choose /path/to/react-native/ReactKit/ReactKit.xcodeproj
- Now ReactKit would have been imported. Link it by choosing it from the list.
- + > lib.ReactKit.a
- Under project Build Settings,
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
// | |
// Device.swift | |
// imHome | |
// | |
// Created by Kevin Xu on 2/9/15. Updated on 6/20/15. | |
// Copyright (c) 2015 Alpha Labs, Inc. All rights reserved. | |
// | |
import Foundation |
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
// Remember to @import WebKit at the top of the class | |
// Javascript that disables pinch-to-zoom by inserting the HTML viewport meta tag into <head> | |
let source: NSString = "var meta = document.createElement('meta');" + | |
"meta.name = 'viewport';" + | |
"meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';" + | |
"var head = document.getElementsByTagName('head')[0];" + | |
"head.appendChild(meta);"; | |
let script: WKUserScript = WKUserScript(source: source, injectionTime: .AtDocumentEnd, forMainFrameOnly: true) |
This gist accompanies the blog post Building NSURL Queries with NSURLQueryItems and NSURLComponents.
In React's terminology, there are five core types that are important to distinguish:
React Elements
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
class var userDateFormatter : NSDateFormatter { | |
struct Static { | |
static let instance: NSDateFormatter = { | |
let dateFormatter = NSDateFormatter() | |
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" | |
return dateFormatter | |
}() | |
} | |
return Static.instance | |
} |
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
import Foundation | |
extension Array { | |
func indexOfObject(object : AnyObject) -> NSInteger { | |
return (self as NSArray).indexOfObject(object) | |
} | |
mutating func removeObject(object : AnyObject) { | |
for var index = self.indexOfObject(object); index != NSNotFound; index = self.indexOfObject(object) { | |
self.removeAtIndex(index) |
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
import Foundation | |
class ABC {} | |
let abc = ABC() | |
// in-out expression can be used for CConstVoidPointer parameter. | |
var key: Void? | |
objc_setAssociatedObject(abc, &key, "value", UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) |
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
extension Int { | |
func times (iterator: () -> Void) { | |
for _ in 0..self { | |
iterator() | |
} | |
} | |
func downto (to : Int, iterator: (Int) -> Void) { | |
var num : Int = self |
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
# --------------------------------------------------------------------------- | |
# | |
# Description: This file holds all my BASH configurations and aliases | |
# | |
# Sections: | |
# 1. Environment Configuration | |
# 2. Make Terminal Better (remapping defaults and adding functionality) | |
# 3. File and Folder Management | |
# 4. Searching | |
# 5. Process Management |