是否可以通过编程方式为mac os x打开/关闭"请勿打扰",这意味着通过代码.我已经通过谷歌做了一些研究,例如:
通过Automator脚本applescripting通知中心调度请勿打扰.顺便说一句,我没有让它工作,当我开始使用NotificationCenter时,请勿打扰开关仍然关闭
通过代码编写默认值,编程等效于默认值写命令,例如如何使用NSUserDefaults,但是如何使用args -currentHost(在上面的链接文章中提到)
我有一个像下面这样的单身APIService
import Foundation
import Alamofire
import SwiftyJSON
typealias Success = JSON -> Void
typealias Failure = NSError? -> Void
class APIService {
private let BaseURL = "http://api.openweathermap.org/data/2.5"
class var instance: APIService {
struct Singleton {
static let instance: APIService = APIService()
}
return Singleton.instance
}
func currentWeather(cityName: String, success:Success?, failure:Failure?) {
let url = BaseURL + "/weather"
Alamofire.request(.GET, url, parameters:["q" : cityName])
.responseJSON { (_, _, jsonObject, error) in
if error != nil && failure != nil {
failure!(error)
} …Run Code Online (Sandbox Code Playgroud)