Learning iOS part 1: Using Delegates in Swift for E-mailing

After working in Android for a while, I am taking the plunge into Swift. Learning the ropes has been fairly easy, except for there are a few differences you must be careful on. This reminds me of learning Portuguese after learning Spanish. There are a lot of words that are alike, but you must not always assume that they are the same.

One of those differences has been nil and null. Apparently null does exist in the iOS world, and is actually used. Nil is used when you are wanting to return a null id, except for an object. If it is a non-object pointer (void*) then you would use null. Some other small differences include not needing to put parenthesis around if statements, and not having to add a semi-colon to the end of everything. Some of these changes have taken a while to get used to, but one thing that is taking a little bit more time to learn how to call system functions to do things like sending an e-mail.

In Android, you would use intents to handle calling system tasks like sending an e-mail. In iOS there is a specified controller that you can switch to after you pass it some extra information. This is much more tightly coupled, but makes the documentation at least pretty straight forward:

Sending files using Swift

The article does warn that you probably should use an actual device, and not a simulator. In the simulator the e-mail comes up, but it soon crashes. As soon as I get my developer account I will update.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s