Swift
Strings #
Interpolation #
let name = "Robb"
let myString = "My name is \(name)"
Replacement #
str.replacingOccurrences(of: "this", with: "that")
Split #
myString.components(separatedBy: " ")
Includes #
let myString = "something cool"
// starts with
myString.starts(with: "something")
// contains
myString.contains("something")
// get first or last
myString.prefix(2) // "so"
myString.suffix(2) // "ol"
Arrays #
Join #
myArray.joined(separator: ", ")
Filter #
let filtered = myArray.filter { $0.count > 1 }
Iterate #
for element in elements {
print(element)
}
// or
elements.forEach { element in
print(element)
}
Index Exists #
myArray.indices.contains(1)
Length of Array #
myArray.count
Links #
- ios - How to get all Events out of a Calendar (Swift) - Stack Overflow
- jordansinger/slack-macos-swiftui-sample: Slack macOS Big Sur SwiftUI example app
- News.swift
- httpswift/swifter: Tiny http server engine written in Swift programming language.
- Recreate - Video series about recreating popular UI with Swift
- Hacking with Swift
- How to detect a URL in a String using NSDataDetector - free Swift 5.4 example code and tips
- JavaScriptCore - NSHipster / Swift
- Swift and JavaScript interaction - DEV Community
- Hacker News