Skip to content

Instantly share code, notes, and snippets.


Yuan, Jun mediter

Block or report user

Report or block mediter

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mediter / error.swift
Created May 20, 2018
[Error Handling] #swift #error
View error.swift
import Foundation
do {
let str = try NSString(contentsOfFile: filePath,encoding:   NSUTF8StringEncoding)//要尝试做的事情
} catch let err as NSError {//如果失败则进入catch代码块
mediter / app_doc_path.swift
Created May 20, 2018
[App Document Directory] #swift #persistence
View app_doc_path.swift
// 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")
mediter / tableview-background.swift
Created May 19, 2018
[Table View Background] #ios #swift #UITableView
View tableview-background.swift
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
mediter / statusbar.swift
Last active May 19, 2018
[Status Bar Height] #swift #ios #statusbar
View statusbar.swift
// get the height of the status bar
let statusBarHeight = UIApplication.shared.statusBarFrame.height
You can’t perform that action at this time.