Skip to content

Instantly share code, notes, and snippets.

View tanduynguyen's full-sized avatar

Duy Nguyen tanduynguyen

View GitHub Profile
@tanduynguyen
tanduynguyen / Notifications.swift
Last active January 5, 2017 05:32
The good way to work with NotificationCenter on Swift 3
enum Notifications: String {
case DidLogin
case DidLogout
case AddToCart
func post(object: AnyObject? = nil) {
NotificationCenter.default.post(name: NSNotification.Name(rawValue: self.rawValue), object: object)
}
@tanduynguyen
tanduynguyen / FontHelper.swift
Last active January 5, 2017 05:33
Print all iOS fonts in Swift 3
UIFont.familyNames.sorted().forEach({
print("Font Family : " + $0)
let names = UIFont.fontNames(forFamilyName: $0)
print("Font Names = \(names)")
print("-------------------------------------------")
})
@tanduynguyen
tanduynguyen / Entity.swift
Last active September 23, 2016 05:27
initWithSpriteSheetNamed
//
// Created by Duy Nguyen on 22/9/16.
//
import SpriteKit
class Entity {
// var mAnimatingFrames = Entity.initWithSpriteSheetNamed("SpriteSheetNamed", sourceRect: CGRectMake(0, 0, 1600, 300), numberOfSprites: 6)
class func initWithSpriteSheetNamed(spriteSheet: String, sourceRect: CGRect, numberOfSprites: Int) -> [SKTexture] {