Created
September 10, 2015 18:15
-
-
Save wickdninja/f8a057acf6fbbe01086b to your computer and use it in GitHub Desktop.
file access swift 1.2
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
// | |
// FileManager.swift | |
// picturepay | |
// | |
// Created by Nate on 3/3/15. | |
// Copyright (c) 2015 alliedpayment. All rights reserved. | |
// | |
import Foundation | |
public class FileManager { | |
class func getUserFromFileWithSuccess(success: ((data: NSData) -> Void)) { | |
//1 | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { | |
//2 | |
let filePath = NSBundle.mainBundle().pathForResource("user",ofType:"json") | |
var readError:NSError? | |
if let data = NSData(contentsOfFile:filePath!, | |
options: NSDataReadingOptions.DataReadingUncached, | |
error:&readError) { | |
success(data: data) | |
} | |
}) | |
} | |
class func getTemplatesFromFileWithSuccess(success: ((data: NSData) -> Void)) { | |
//1 | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { | |
//2 | |
let filePath = NSBundle.mainBundle().pathForResource("templates",ofType:"json") | |
var readError:NSError? | |
if let data = NSData(contentsOfFile:filePath!, | |
options: NSDataReadingOptions.DataReadingUncached, | |
error:&readError) { | |
success(data: data) | |
} | |
}) | |
} | |
class func getPaymentsFromFileWithSuccess(success: ((data: NSData) -> Void)) { | |
//1 | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { | |
//2 | |
let filePath = NSBundle.mainBundle().pathForResource("payments",ofType:"json") | |
var readError:NSError? | |
if let data = NSData(contentsOfFile:filePath!, | |
options: NSDataReadingOptions.DataReadingUncached, | |
error:&readError) { | |
success(data: data) | |
} | |
}) | |
} | |
class func getElectricDeliveryOptionsFromFileWithSuccess(success: ((data: NSData) -> Void)) { | |
//1 | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { | |
//2 | |
let filePath = NSBundle.mainBundle().pathForResource("elecDeliveryOptions",ofType:"json") | |
var readError:NSError? | |
if let data = NSData(contentsOfFile:filePath!, | |
options: NSDataReadingOptions.DataReadingUncached, | |
error:&readError) { | |
success(data: data) | |
} | |
}) | |
} | |
class func getPaperDeliveryOptionsFromFileWithSuccess(success: ((data: NSData) -> Void)) { | |
//1 | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { | |
//2 | |
let filePath = NSBundle.mainBundle().pathForResource("paperDeliveryOptions",ofType:"json") | |
var readError:NSError? | |
if let data = NSData(contentsOfFile:filePath!, | |
options: NSDataReadingOptions.DataReadingUncached, | |
error:&readError) { | |
success(data: data) | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment