Embracing the Swift Standard Library.

Swift is a truly powerful language. But a powerful language is nothing if it doesn’t have a powerful standard library. In this post we will get started with the Swift Standard library (which is small compared to the standard library of other languages, but by no means does that mean it isn’t powerful). The Swift Standard library goes hand in hand with Apple’s new programming paradigm – Protocol-Oriented Programming. If you are acquainted with Protocol-Oriented Programming, you know how different it is compared to the so-known OOP. Swift’s Standard Library adopts Protocol-Oriented Programming really well (and that’s to be expected, since they created this paradigm!) To be more specific, we will explore three protocols from Swift’s Standard Library here – GeneratorType, SequenceType and ArrayLiteralConvertible. We are going to build a Shopping List that behaves like an array – You will be able to create a Shopping List passing it an array of Shopping Items, and you will be able to fast-iterate (using for-in) over this list to get its elements as if it were a normal array. But this shopping list also has its own methods, so we are not just creating a new array with a fancy name. A Simple Shopping List If you wanted to create a shopping list of things, you would probably start by creating a class or an struct (in this post, we will use an struct to also embrace the power of value types in Swift). This struct would probably represent a simple shopping item, with a name and a price. struct ShoppingItem { let name: String let price: Float init(name: String, price:...

Installing Ghost In an Ubuntu Server with Virtualmin and Apache

Ghost I was arguing with myself whether I should post this or not. For one, it is the second Linux-related tutorial I write, and that strays from the main topic of my site (my awesome self and iOS development). But because installing Ghost was a big hassle on my current setup, I decided to write this for those who are struggling with the same thing as me. After all, I have said this before – one of the reasons I decided to start blogging was so I could also start documenting things for myself. Most, if not all, of my tutorials, have been things I have written shortly after having learned about them. So I know that my own site is a good go-to reference when I need to use those topics again. At the time of this writing, Ghost 0.5 has just been released to the public. There are many changes, and there aren’t too many sources you can find to help you install Ghost on Ubuntu, using Virtualmin (Webmin, in case you only have access to that – this tutorial should work for both). In fact, in all my searches, the total amount of resources I found that talked about Ghost and Virtualmin or Webmin in the same page was a grand total of zero. For this reason, I will document how I managed to install Ghost on my server, which is running Ubuntu server with a Virtualmin setup. If you are like me, you just hate to do server administration by hand using the Terminal and sending off the commands, and installed Virtualmin to make your...

Using The iOS Keychain.

Keychain If you’re a developer, you know you will, you know you will have to store sensitive data in your app sooner or later. Storing sensitive data in NSUserDefaults is a big no-no, so you just can’t store sensitive data there. Instead, just like OS X, iOS provides a keychain your app can use to store all sorts of sensitive data. The keychain is they key place to store all those user passwords or bank information your app may need to store in the app. If you are just starting with iOS development, or just mid-level, the idea of having to store sensitive data is scary. The good news is, iOS has a very easy API to use with the keychain. Interacting with the keychain on iOS is very simple as the API is composed of just four essential functions. The Keychain Essentials. The iOS Keychain Is Much Different Than The OS X Keychain The OS X keychain is much, much more complex than the iOS keychain. This tutorial is specifically for the iOS keychain. First, in OS X, any app can request access to any info currently stored in the keychain. If you’re an OS X user, you may recall those prompts notifying you that a given app would like to access data in your keychain. They look like this:   Once you put in your password, the keychain will open and grab the data it needs, and hand it over to the app requesting access to it. Second, the OS X Keychain has one more feature you cannot find in iOS, and this is one of the...

Making A Linux File Server That Interacts With OS X Mavericks.

Making A Linux File Server That Interacts With OS X Mavericks. This is a non-development tutorial, but with Mavericks being really new there are no tutorials to make your file server interact with the OS smoothly. Because of this, I’m writing this small tutorial to setup your server to share files with OS X Mavericks. This may or may not work with OS X Lion and OS X Mountain Lion, but you lose nothing trying, right? Last weekend I decided to ditch my Windows Desktop altogether and to make my beautiful 27” Inch iMac my main computer. The reason I stuck with Windows for so long is that I just cannot stash thousands of Gigabytes in my iMac. In other words, storage was the only reason I was using Windows. But then I thought, wouldn’t it be great to kill my Windows setup altogether, and convert all this hardware into a file server? I said yes, and that’s exactly what I did. I’m incredibly illiterate when it comes to Linux and file servers. This was my first time setting a file server, actually. I was going to use FreeNAS. I looked at many OS alternatives for this, but I decided to stick with Ubuntu. If you’re in a similar situation, follow along this tutorial and hopefully by the end of it you will have a working Ubuntu file server that can communicate painlessly with your Mac. 1. Things to Consider: Your File Server Won’t use AFP. If you don’t have much of a technical background and just want to have your file server up and running, feel free to...

Creating Aggregate Projects on Theos: A Configurable Tweak.

Creating Aggregate Projects on Theos: A Configurable Tweak. More often than not, you will want to create a Theos project that is composed of one or various subprojects. A very common case for this would be to write a Tweak that can be configured by the user (guess what we’re writing today…): You’d create a Tweak project that contains a PreferencesLoader subproject that is in charge of writing the tweak’s behaviour. Aggregrate projects with Theos are very easy to build. In this tutorial we’re going to write an Aggregate project that does just that: We will write a very simple tweak with a simple PreferencesLoader that will decide whether the tweak should alert the user when the app has been launched or not. You have seen this simple tweak in action before: I wrote it in my Writing a MobileSubstrate Tweak for iOS tutorial. In fact to save us the time, I will assume you followed that tutorial, and that you managed to compile it and run it. We will write the same tweak with a twist. In that way we will save us the trouble of writing a MobileSubstrate tweak and get straight to the point of this tutorial. In this tutorial… You’ll learn the basics of a PreferencesLoader project (Note that this is NOT the same a Settings.bundle found in App Store apps, but they can share similarities). You will learn to write aggregate projects with Theos. An aggregate project is a project that contains one or more sub projects. The following assumptions are made: You know how to write iOS apps. You know the SDK and...

Writing SBSettings Toggles: A Tutorial.

SBSettings Toggles In this tutorial, I will help you getting started with SBSettings Toggles, using Theos. Writing SBSettings Toggles is actually a really easy thing to do. SBSettings Toggles only have a handful of functions you must implement. The most trivial SBSettings Toggles don’t need any complex hooking, so teaching how to write them is not hard either. More complex SBSettings Toggles, like you may expect, need to either have some hooking or modify some system plists. If you have followed my other tutorials, you know I like giving theory first and then go practical by writing something. This case won’t be any different. Although the toggle we will be writing is going to be really, really simple: We will simply write a toggle that changes the display type in the Weather app (That is, when toggled, it will show in Celsius: When not, it will display in Fahrenheit). Writing SBSettings Toggles? First, Understand the Theory. If you’re here because you had problems reading BigBoss’ SBSettings Toggles Specifications, the first part of this tutorial is based on his theory. After all, I went to him to learn about SBSettings Toggles myself. Needless to say, I will explain things differently here, so if you had problems with the “Official Guide”, this one may still give you hope. SBSettings is a modular application. All SBSettings Toggles are separate projects. The settings app looks for the togges in /var/mobile/Library/SBSettings/Toggles, and all SBSettings Toggles are given the name of the folder they are in. Toggles are said to be “ON” by default; They are said to be “OFF” when their folders contain a...