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 Foundation | |
do { | |
//要做一些操作 | |
let str = try NSString(contentsOfFile: filePath,encoding: NSUTF8StringEncoding)//要尝试做的事情 | |
} catch let err as NSError {//如果失败则进入catch代码块 |
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
// MARK: - Data Persistence | |
func documentsDirectory() -> URL { | |
let paths = FileManager.default.urls(for: .documentDirectory, | |
in: .userDomainMask) | |
return paths[0] | |
} | |
func dataFilePath() -> URL { | |
return documentsDirectory().appendingPathComponent("Checklists.plist") | |
} |
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
tableView.backgroundColor = UIColor(red:1, green:1, blue:1, alpha:1.00) | |
let backgroundImageView = UIImageView(frame: view.bounds) | |
backgroundImageView.image = UIImage(named: "background") | |
backgroundImageView.alpha = 0.5 | |
tableView.backgroundView = backgroundImageView |
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
// get the height of the status bar | |
let statusBarHeight = UIApplication.shared.statusBarFrame.height |
NewerOlder