This file contains hidden or 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
enum Env: String { | |
case debug | |
case testFlight | |
case appStore | |
} | |
struct App { | |
struct Folders { | |
static let documents: NSString = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString | |
static let temporary: NSString = NSTemporaryDirectory() as NSString |
This file contains hidden or 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
let alertController = UIAlertController(title: nil, message: "Alert message.", preferredStyle: .actionSheet) | |
let defaultAction = UIAlertAction(title: "Default", style: .default, handler: { (alert: UIAlertAction!) -> Void in | |
// Do some action here. | |
}) | |
let deleteAction = UIAlertAction(title: "Delete", style: .destructive, handler: { (alert: UIAlertAction!) -> Void in | |
// Do some destructive action here. | |
}) |
This file contains hidden or 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
let alertController = UIAlertController(title: nil, message: "Alert message.", preferredStyle: .actionSheet) | |
let defaultAction = UIAlertAction(title: "Default", style: .default, handler: { (alert: UIAlertAction!) -> Void in | |
// Do some action here. | |
}) | |
let deleteAction = UIAlertAction(title: "Delete", style: .destructive, handler: { (alert: UIAlertAction!) -> Void in | |
// Do some destructive action here. | |
}) |
This file contains hidden or 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
let redBox = UIView(frame: CGRect(x: 100, y: 100, width: 128, height: 128)) | |
redBox.backgroundColor = .red | |
redBox.layer.cornerRadius = 25 |
This file contains hidden or 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
extension UIView { | |
func roundCorners(corners: UIRectCorner, radius: CGFloat) { | |
let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius)) | |
let mask = CAShapeLayer() | |
mask.path = path.cgPath | |
layer.mask = mask | |
} | |
} | |
This file contains hidden or 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
// 1 import | |
import CoreMotion | |
// 2 create property that can store CMMotionManager | |
var motionManager: CMMotionManager! | |
// 3 initialize it | |
motionManager = CMMotionManager() | |
// 4 check accelermoter is available |
This file contains hidden or 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 SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
VStack { | |
Text("Hello, world!") | |
Image(systemName: "swift") | |
} | |
} | |
} |
This file contains hidden or 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: var, let 이해 | |
let numOfEyes = 2 | |
var fisrtName = "John" | |
// MARK: Array, Dictionary 이해 | |
let scores: [Int] = [56, 92, 100, 80] | |
let firstScore = scores[0] |
This file contains hidden or 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
extension UIDevice { | |
var hasNotch: Bool { | |
let bottom = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0 | |
return bottom > 0 | |
} | |
} | |
if UIDevice.current.hasNotch { | |
//... consider notch |
This file contains hidden or 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
extension String { | |
func trimTrailingWhitespaces() -> String { | |
return self.replacingOccurrences(of: "\\s+$", with: "", options: .regularExpression) | |
} | |
} | |
let string = "there is string with trailing whitespace " | |
let trimmed = string.trimTrailingWhitespaces() |
NewerOlder