This file contains 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
func randomFloat(from from:CGFloat, to:CGFloat) -> CGFloat { | |
let rand:CGFloat = CGFloat(Float(arc4random()) / 0xFFFFFFFF) | |
return (rand) * (to - from) + from | |
} | |
func randomInt(n: Int) -> Int { | |
return Int(arc4random_uniform(UInt32(n))) | |
} |
This file contains 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
func savePhotoToLibrary(image: UIImage) { | |
let photoLibrary = PHPhotoLibrary.shared() | |
photoLibrary.performChanges({ | |
PHAssetChangeRequest.creationRequestForAsset(from: image) | |
}) { (success: Bool, error: Error?) -> Void in | |
if success { | |
// Set thumbnail | |
self.setPhotoThumbnail(image: image) | |
} else { | |
print("Error writing to photo library: \(error!.localizedDescription)") |
This file contains 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
var data = [String]() | |
var dataDescription = [String]() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
if let myPath = NSBundle.mainBundle().pathForResource("data", ofType: "plist") { | |
if let arrayOfDictionaries = NSArray(contentsOfFile: myPath) { | |
for dict in arrayOfDictionaries { | |
data.append(dict.objectForKey("title") as! String) |
This file contains 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
var tableData = [String]() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
var dict: NSDictionary? | |
if let path = NSBundle.mainBundle().pathForResource("TableData", ofType: "plist") { | |
dict = NSDictionary(contentsOfFile: path) | |
} |
This file contains 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 GameKit | |
class GameScene: SKScene, GKGameCenterControllerDelegate { | |
var gcEnabled = Bool() | |
var gcDefaultLeaderboard = String() | |
var LeaderboardID = "com.endodoug.MagicalLeaderboard" | |
} | |
override func didMoveToView(view: SKView) { | |
AuthenticateLocalPlayer() |
This file contains 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 UIKit | |
import MessageUI | |
import Foundation | |
class ViewController: UIViewController, MFMailComposeViewControllerDelegate { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} |
This file contains 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |