Sometimes there is a need to use or test some property outside the enclosing declaration (internal get). At the same time, you don’t want this property to be modified outside – because, by applying good practices and for safety reasons,…
Category: swift tips
Be careful about getting elements from an array
You have to remember that in Swift, if you try to access an index that is out of bounds, you will get a runtime error (EXC_BAD_INSTRUCTION) and the application will crash. Currently, Swift Array type doesn’t have a safe method…
Can encoding a String to Data with utf8 fail?
Surely none of us programming in Swift likes force-unwrapping optional values too much (we prefer a ‘guard’ – although excessive use is also not quite the right approach). Quick reminder for beginners: optionals represent data that may or may not…