Skip to content

Instantly share code, notes, and snippets.

@MTattin
Last active November 23, 2016 08:50
Show Gist options
  • Save MTattin/228e6e7239564e665b62452b72443d33 to your computer and use it in GitHub Desktop.
Save MTattin/228e6e7239564e665b62452b72443d33 to your computer and use it in GitHub Desktop.
let _0_delay = 3.0 * Double(NSEC_PER_SEC)
let _0_time = DispatchTime.now() + Double(Int64(_0_delay)) / Double(NSEC_PER_SEC)
DispatchQueue.main.acyncAfter(deadline: _0_time, execute: {
})
DispatchQueue.main.acyncAfter(deadline: DispatchTime.now() + Double(Int64(3.0 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: {
})
DispatchQueue.main.async(execute: { [weak self] in
guard let _0_weakSelf = self else { return }
})
#selector(Class.method(_:)) // before
#selector(Class.method(name:)) // after
#selector(Class.method(_:)) // before
#selector(Class.method(name:)) // after
let s: [String] = str.componentsSeparatedBy("=") // before
let s: [String] = str.components(separatedBy: "=") // after
let s: [String] = str.componentsSeparatedBy("=") // before
let s: [String] = str.components(separatedBy: "=") // after
/// before
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.all
}
override func prefersStatusBarHidden() -> Bool {
return true
}
override func preferredStatusBarStyle:() -> UIStatusBarStyle {
return UIStatusBarStyle.lightContent
}
/// after
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.all
}
override var prefersStatusBarHidden: Bool {
return true
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return UIStatusBarStyle.lightContent
}
let req: NSMutableURLRequest = NSMutableURLRequest(url: url)
let config: URLSessionConfiguration = URLSessionConfiguration.default()
/* setup post data */
let data: NSMutableData = NSMutableData()
if let td: Dictionary = txtD {
for txtKey: String in td.keys {
if let txtVal: String = td[txtKey] {
data.append(NSString(format: "--%@\r\n", CommonSession._Boundary).data(using: String.Encoding.utf8.rawValue)!)
data.append(NSString(format: "Content-Disposition: form-data;").data(using: String.Encoding.utf8.rawValue)!)
data.append(NSString(format: "name=\"%@\"\r\n\r\n", txtKey).data(using: String.Encoding.utf8.rawValue)!)
data.append(NSString(format: "%@\r\n", txtVal).data(using: String.Encoding.utf8.rawValue)!)
}
}
}
/* add last boundary */
let d: Data = NSString(format: "--%@--\r\n", CommonSession._Boundary).data(using: String.Encoding.utf8.rawValue)!
data.append(d)
/* setup post request */
req.httpMethod = "POST"
req.httpBody = data as Data
let session: URLSession = URLSession(configuration: config, delegate: nil, delegateQueue: nil)
let task: URLSessionDataTask = session.dataTask(with: req as URLRequest, completionHandler: { [weak self] (data, response, error) in
do {
} catch let e as NSError {
}
})
func SampleFunc(n: NSNotification) {
guard
let name: String = n.name.rawValue where name == "通知の名前",
let info: [NSObject : AnyObject] = n.userInfo
else {
return
}
}
NotificationCenter.default.post(name: Notification.Name(rawValue: "通知の名前"), object: nil)
NotificationCenter.default.post(name: Notification.Name(rawValue: "通知の名前"), object: nil)
if let u: String = "http://www.tes.com/あいうえお".addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) {
return u
}
override func observeValue(forKeyPath keyPath: String?, of object: AnyObject?, change: [NSKeyValueChangeKey : AnyObject]?, context: UnsafeMutablePointer<Void>?) {
}
override func observeValue(forKeyPath keyPath: String?, of object: AnyObject?, change: [NSKeyValueChangeKey : AnyObject]?, context: UnsafeMutablePointer<Void>?) {
}
CGRect(x: 0, y: 0, width: 0, height: 0)
CGSize(width: 0, height: 0)
CGRect(x: 0, y: 0, width: 0, height: 0)
CGSize(width: 0, height: 0)
extension CGRect {
static func Make(_ x: CGFloat, _ y: CGFloat, _ w: CGFloat, _ h: CGFloat) -> CGRect {
return CGRect.init(x: x, y: y, width: w, height: h)
}
static var Zero: CGRect {
get {
return CGRect.init(x: 0, y: 0, width: 0, height: 0)
}
}
}
let a: CGRect = CGRect.Make(0, 0, 0, 0)
let b: CGRect = CGRect.Zero
extension CGRect {
static func Make(_ x: CGFloat, _ y: CGFloat, _ w: CGFloat, _ h: CGFloat) -> CGRect {
return CGRect.init(x: x, y: y, width: w, height: h)
}
static var Zero: CGRect {
get {
return CGRect.init(x: 0, y: 0, width: 0, height: 0)
}
}
}
let a: CGRect = CGRect.Make(0, 0, 0, 0)
let b: CGRect = CGRect.Zero
CGAffineTransform.identity
CGAffineTransform(scaleX: x, y: y)
CGAffineTransform(translationX: x, y: y)
CGAffineTransform.identity
CGAffineTransform(scaleX: x, y: y)
CGAffineTransform(translationX: x, y: y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment