Weak vs. Strong References in Swift

Aasif
By Aasif | December 9, 2021 6:15 pm  | 5-min read

Creating a strong reference to an instance in Swift, means that the instance is kept in the iPhone’s memory until you’re done with it. You can also create weak references. Both are part of the memory management mechanism called ARC. In this tutorial, we’ll discuss how weak and strong references work on iOS with Swift. Here’s what we’ll get into: What’s a strong reference, and why do we need it? Weak vs. strong references and how they affect your code How to avoid strong refer [...]

Read More

Self and self in Swift

Aasif
By Aasif | December 9, 2021 5:21 pm  | 4-min read

In Swift, “self” typically refers to the current object within a class or struct. We’ve got more selves though: self, Self and even .self. What does it all mean? Get ready for a bit of introspection and metaprogramming – we’re going to discover the Self in Swift. Don’t worry, no New Age stuff involved! Here’s what we’ll discuss: What’s self and Self in Swift How to use self when you’re working with classes or closures When you need to use self, and when it’s implici [...]

Read More

Fixing The «Unrecognized Selector Sent to Instance» Error in Xcode

Aasif
By Aasif | December 9, 2021 4:41 pm  | 4-min read

The “Unrecognized selector sent to instance” is an annoying error in Xcode. With Swift’s syntax improvements this error occurs less often, but it still pops up every now and then. How do you solve it? In this tutorial, you’ll learn to debug Unrecognized selector sent to instance. We’ll discuss where the error comes from and how to solve it. Debugging is part of becoming an effective iOS developer. Fixing errors is a great way to learn more about iOS development, so take your time [...]

Read More

1x, 2x and 3x Image Scaling on iOS Explained

Aasif
By Aasif | December 9, 2021 4:13 pm  | 4-min read

How does image scaling work on iOS, and what does @2x mean? Different iPhone and iPad models have different screen sizes and pixel densities (PPI). This affects the graphics assets, images and artwork you’re going to use in your iOS app. In this tutorial, you’ll learn more about: The difference between points and pixels When to use 1x, 2x and 3x image scaling File naming conventions with @2x and @3x How to keep working with different screen resolutions simple Recommended tools and [...]

Read More

Conditionals in Swift with If, Else If, Else

Aasif
By Aasif | December 9, 2021 3:42 pm  | 6-min read

You use conditionals to make decisions in your Swift code, with if, else if and else. If this happens, then do that. This is called control flow, because you use it to control the way your code flows. In this tutorial you’ll learn how to use the if-statement in your Swift code. We’ll get into boolean logic, expressions, operators, and the syntax of if, else if and else blocks. In practical iOS development you use conditionals all the time. Logic expressions can be especially hard to gr [...]

Read More

Most Popular Posts