Swift - Sizuha/devdog GitHub Wiki
iOS ๊ฐ๋ฐํ๊ฒฝ์ ๊ธฐ์ค์ผ๋ก ์ค๋ช ํจ.
Version ็ขบ่ช
$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -v
๋ฌธ๋ฒ
- Swift ๋ฌธ๋ฒ ์ฐธ์กฐ.
- Swift ๋ฌธ๋ฒ ์ฌํ ์ฐธ์กฐ.
Regular Expression
์ฐธ๊ณ
NSRegularExpression ํด๋์ค๋ฅผ ํ์ฉ.
/// ่ฑๆฐๅญใฎ็ตใฟๅใใใงใๅคงๆๅญใฏๅฟ
ใไธใคๅ
ฅใฃใฆใใใใจใ็ขบ่ช
/// - Parameter password: ใในใฏใผใ
public func checkValidation(password: String) -> Bool {
let regx = try? NSRegularExpression(pattern: "^(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]{8,32}$")
let range = NSRange(location: 0, length: password.count)
return regx?.numberOfMatches(in: password, options: [], range: range) == 1
}
๋ ์ง/์๊ฐ
๋ ์ง ์๊ฐ ํํ ๋ฐฉ์์ด ๊ธฐ๋ณธ์ ์ผ๋ก ์์คํ ์ ์ค์ ์ ๋ฐ๋ผ๊ฐ๊ธฐ ๋๋ฌธ์, ํ์ค์ ์ธ ๋ฐฉ์์ผ๋ก ์ฒ๋ฆฌํ๊ธฐ ์ํด์๋ TimeZone, Locale ๋ฑ์ ์ง์ ์ง์ ํด ์ค ํ์๊ฐ ์๋ค.
let utcTimeZone = TimeZone(abbreviation: "UTC")!
let standardLocal = Locale(identifier: "en_US_POSIX")
let fmt = DateFormatter()
fmt.locale = standardLocal
fmt.dateFormat = "yyyy-MM-dd HH:mm:ss"
fmt.timeZone = utcTimeZone
URL
๊ฒฝ๋ก๋ง ์ป๊ธฐ
let url = URL(fileURLWithPath: "/foo/bar/file.text")
let dirUrl = url.deletingLastPathComponent()