In part 2 of this post on Swift's protocols, you will learn practical uses for declaring custom protocols in your own apps, and learn further how they improve the architecture of your apps and make them easier to enhance and extend.
In part 1 of this post, I demonstrated how to implement existing Cocoa Touch protocols in your apps. Now you'll learn how and why to create your very own. First, we need to cover the basic construction of a Swift protocol.
If you want to quickly call, FaceTime, or text a contact, there's no need to open any of the related apps. Those who have iOS 8 on their iPhone can quickly access Favorite and Recent contacts via the App Switcher.
As anyone who has used to Siri to make calls, search the web, or send messages knows, Siri doesn't always understand what you say. This can be followed by increasing frustration levels if Siri fails over and over to understand your voice corrections. But when Siri gets it wrong, you don't have to repeat yourself. Instead, you can edit your query via typing.
Thanks to iOS 8, Apple lovers finally have access to widgets on their iPhones. But users will find some widgets more useful than others. Maximize their utility by deleting widgets you don't need to see in the Today view in Notifications and arranging the rest in the most convenient order.
You know the feeling—you hand your phone over to a friend or family member, intending to show them a single picture, and suddenly you’re watching in horror as they begin swiping through your 50+ selfies or stumble across your hoard of risqué photos. Thankfully, iOS 8 has introduced an easy way for you to hide your shots from prying eyes with its new "hide" feature.
Stop checking your inbox every five minutes for that reply to the email you sent. Enable reply notifications instead so you receive an alert whenever a reply in an important email thread arrives.
You don't have to leave a group message just because you want your iPhone to stop buzzing with new message notifications. Instead you can turn on Do Not Disturb for that message thread and read all the messages about planning your brother-in-law's birthday party later.
Protocols are a powerful, advanced tool that help make your apps easier to design and extend. They define standard behavior in classes that are not necessarily related. Protocols used together with delegates allow you to create classes with a well-balanced load of responsibilities.
Using Find My iPhone can significantly increase the odds that your lost iPhone will be returned to you. But it won't work if the battery is dead. With iOS 8, you now have the ability to have your missing iPhone send its location to Apple just before the battery dies. This is probably most useful when looking for a lost iPhone. A stolen phone is more likely to be moved after the battery dies.
Messages can take up a surprising amount of your iPhone's storage capacity and the reason is all those cute pictures of dogs and kids that you've been texting back and forth with your friends. Fortunately, it's easy to delete attachments from Messages without deleting the conversation.
I like the features of Safari in iOS 8. In a previous tip I showed how to request the desktop version of a site by tapping in the address bar and then dragging down on the Favorites window that pops up. I also just learned of a quick way to add the current page to Favorites, to your reading list, or to shared links.
I like Apple's Maps app, but a number of times it's taken me to a location that simply didn't exist: an Indian restaurant, a zoo, a hotel in a small town, a Chinese restaurant. I diligently follow Siri's directions and when she says I've arrived, the establishment in question is nowhere to be seen. And in several of these cases probably never existed. If you've had similar problems and prefer maps from third parties such as Google, you can now conveniently access these maps from within Apple's Maps app.
Often when you're searching the web for some particular bit of information, your search pulls up a long page of text. But you then have no idea where on that page to find the information you're looking for. The next step is to search within the page. The way to do that on iOS devices is simple, but not obvious.
In previous posts I have touched on inheritance in Swift. In this post, I'm going to be diving deeper and giving you a fuller picture of how inheritance works in Swift, and how you can use it to create apps that are easy to extend when you need to add new functionality. Along the way, you will also learn about the important concept of polymorphism and learn how to use Xcode's new playgrounds!
One of the useful features of email is being able to see exactly when an email was sent. However, unlike Mail, the default view in Messages doesn't show the time when messages in a thread were sent. Messages are time-stamped just as emails are—you simply need to know how to view the time stamp.
One of the great new features in iOS 8 is the ability to send an audio message. Sometimes it's simply a lot more convenient to make a quick recording than it is to type a message. Why not simply call the person? Because convention requires that we then engage in conversation. An audio message is more efficient. And the party you're sending it to can listen at his or her convenience rather than having to answer the phone.
One of the great features of our mobile devices is the ease with which we can share photos and videos. You can use your iPhone or iPad to send multiple photos via email or messaging. Note that there's a limit of five photos via email, but not via messaging.
You may have had the experience of working on a draft of an email but then needing to look at a different email in your inbox. But the draft obscured the screen and couldn't be quickly be pushed aside and then returned to. Fortunately, Mail in iOS 8 has remedied this situation. You can swipe away a draft, access your other email, and then quickly bring it back into view to continue working on it. This is typically referred to as "minimizing" the email draft.
One of the useful new features of iOS 8 is the ability to view the desktop version of a website in Safari rather than the mobile version — saving me a lot of frustration. For years I’ve had a personalized Yahoo page that's well organized into three columns: 1) stocks, sports, weather, 2) top news, science news, Doonesbury, and 3) Apple news sites. So it was really disorienting when I would go to my Yahoo page on my iPad and all the news feeds would be in two columns with the order all jumbled up. The first time I used this new iOS 8 feature to request the desktop site, my response was: hallelujah!
If you have read Apple's documentation on Generics and were left wondering how you could use this technology in your own projects, this post is for you! You will learn how to take full advantage of generics in your every-day code as well as how to avoid the constant type-casting that usually results from creating generalized code.
Want more? Get our weekly newsletter: