SwiftBites πŸ‘©β€πŸ’»πŸ§‘πŸ»β€πŸ’» (@SwiftBriefing) header
SwiftBites πŸ‘©β€πŸ’»πŸ§‘πŸ»β€πŸ’» (@SwiftBriefing) profile picture

Bitesize learning on Swift Development & Apple Ecosystem

Joined August 2021
Photo by SwiftBites πŸ‘©β€πŸ’»πŸ§‘πŸ»β€πŸ’» (@SwiftBriefing)Photo by SwiftBites πŸ‘©β€πŸ’»πŸ§‘πŸ»β€πŸ’» (@SwiftBriefing)Photo by SwiftBites πŸ‘©β€πŸ’»πŸ§‘πŸ»β€πŸ’» (@SwiftBriefing)Photo by SwiftBites πŸ‘©β€πŸ’»πŸ§‘πŸ»β€πŸ’» (@SwiftBriefing)Photo by SwiftBites πŸ‘©β€πŸ’»πŸ§‘πŸ»β€πŸ’» (@SwiftBriefing)Photo by SwiftBites πŸ‘©β€πŸ’»πŸ§‘πŸ»β€πŸ’» (@SwiftBriefing)Photo by SwiftBites πŸ‘©β€πŸ’»πŸ§‘πŸ»β€πŸ’» (@SwiftBriefing)Photo by SwiftBites πŸ‘©β€πŸ’»πŸ§‘πŸ»β€πŸ’» (@SwiftBriefing)Photo by SwiftBites πŸ‘©β€πŸ’»πŸ§‘πŸ»β€πŸ’» (@SwiftBriefing)Photo by SwiftBites πŸ‘©β€πŸ’»πŸ§‘πŸ»β€πŸ’» (@SwiftBriefing)
"Developers can choose a topic and ask questions about technology usage and adoption, refining their designs, resolving issues, and understanding guidelines and tools" apple.com/newsroom/2021/10/a…
Methods added as extension in the protocol are statically dispatched; a conforming type cannot override methods in an extension. To resolve this, add the method as a requirement of the protocol, while keeping the default implementation in the extension #Swift
Methods in protocol extension are not part of the requirement of the protocol. They can be used to provide default implementation of the protocol or add "free" functionality to conforming types. #Swift #SwiftLang
Associate type can be used in protocol to define common interface for multiple object. This allows logic to be reused in different type and prevent duplicate codes. #Swift
1
When a type conforms to protocol, a protocol witness is passed whenever an instance of that type is constructed. Witness contains the requirement in the protocol that allows operations to be fulfilled (etc == in Equatable ). Explicit Witness can also be created in Struct #Swift
1
String in Swift does not conform to MutableCollection; String does not support replacing a character using subscript operator. It does conform to RangeReplaceableCollection; replaceSubrange is needed even when replacing a character in String #Swift #SwiftLang
1
A String in Swift is a collection of Character values. A single character is what a human reader would perceive, regardless of how many Unicode scalars it’s composed of. Hence, characters have variable width, and String does not support random access. #Swift
1
Jumping to arbitrary character in a string is not O(1) operation
Xcode Shortcut: Jump to method/property When working on large file, press "Control + 6" to display all properties & method in the current file and jump to it base on your selection #Xcode
Matching cases in Enum Underscore _ can be used to match any value and ignore it. It is useful to ignore one part of associated value while matching the other. let can be used to bind part or all the matched value to a new constant to be use in the matched case #Swift
1
The self parameter implicitly passed into every method of Struct is immutable by default. Set the method as mutating to consider self as a var, so the method can change properties on the Struct instance. Instance of Struct needs to be a var to call the mutating method #Swift
2
Autoclosure is a closure that wraps an expression that’s being passed as an argument to a function, so braces can be omitted around a function's parameter. Autoclosure allows delay evaluation, because the code inside isn’t run until the closure is called. #Swift
Lazy Properties 1. Must always be declared as var since its value may not be set until after initialisation 2. Cannot be defined in an extension 3. Accessing lazy property is a mutating operation, an instance of Struct need to be declare as var to access its lazy property #Swift
SwiftBites πŸ‘©β€πŸ’»πŸ§‘πŸ»β€πŸ’» retweeted
⚠️PSA for All iOS Developers: Xcode 12 is not compatible with Monterey. Don’t upgrade your Mac to Monterey unless you are 100% sure that you will only need to use Xcode 13+. developer.apple.com/news/?id…
22
96
19
245
Region Monitoring using CLLocationManager object Region monitoring send alerts when user enters or exits a defined geographical region. Core Location prevents monitoring of more than 20 regions simultaneously. The regions should be updated when user's location changes. #iOSDev
Xcode Keyboard Shortcuts Press "Command + k" to clear console before running the project again #Xcode #iOSDev
1
Location Monitoring when App is in Background: Beside getting user's permission for . requestAlwaysAuthorization and checking didUpdateLocations method in CLLocationManagerDelegate, check that Signing & Capabilities > Background Mode > Location updates is turned on #iOSDev
UIRequiredDeviceCapabilities Property List Key App Store prevents customers from installing an app on a device that doesn’t support the required capabilities for that app. Use UIRequiredDeviceCapabilities key to declare the capabilities your app requires to function #iOSDev
SwiftUI's @AppStorage Property Wrapper provide read/write access to user defaults. When the wrapped value change, its view is recomputed base on the new value #SwiftUI