Coding Explorer Blog

Exploring how to code for iOS in Swift and Objective-C

  • Home
  • Apps
  • About
  • Contact

Archives for April 2015

Pattern Matching in Swift

Xcode 11.6 Swift 5.2.4

Last updated on August 12, 2020

Pattern matching is a staple of functional languages.  At its core, Swift is primarily an object-oriented language, like Objective-C is.  However, there are many advantages to the way more functional style languages like Haskell and Erlang do things that the designers of Swift decided to include.  Pattern matching in particular, saves us having to type much longer, and less readable statements to do the same checks.

I mean, which is easier to read:

case (_, 0, 0):

or

if (someTuple.1 == 0) && (someTuple.2 == 0)

They both will find the same thing, but one can be used in a switch statement, and the other has to dig into the internals of a tuple and write a much longer looking comparison to 0 for each.  Not to mention the logical && there, to make sure both of them are true.
[Read more…]

Filed Under: Swift Tagged With: Swift

Choosing Images with UIImagePickerController in Swift

Xcode 11.6 Swift 5.2.4

Last updated on August 12, 2020

If your Swift iOS app needs to import a picture from the user’s device, you’ve come to the right place today.

Let’s learn how to use UIImagePickerController to let the user select a photo from their device to load into your app.
[Read more…]

Filed Under: Tutorial Tagged With: Swift

Subscribe to the Coding Explorer Newsletter

* indicates required

Follow Us

Facebooktwitterrss

Recent Posts

  • Error Handling in Swift
  • Creating and Modifying a URL in your Swift App
  • Watch Connectivity in Swift — Application Context
  • watchOS Hello World App in Swift
  • API Availability Checking in Swift

Categories

  • Class Reference
  • General
  • Interface Builder
  • My Apps
  • Objective-C
  • Swift
  • Syntax
  • Tutorial
  • Uncategorized

Archives

  • May 2016
  • March 2016
  • February 2016
  • December 2015
  • July 2015
  • June 2015
  • April 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • January 2014
  • November 2013
  • September 2013
  • August 2013
  • July 2013
  • Terms Of Use
  • Privacy Policy
  • Affiliate Disclaimer

Subscribe to the Coding Explorer Newsletter

* indicates required

Copyright © 2025 Wayne Media LLC · Powered by Genesis Framework · WordPress