A comparison between Kotlin and Swift: Collections

Similar to Swift, collection in Kotlin includes: List Set Map 1. List Features of List: May have duplicate element May hold different data types All elements are unordered Similar to array in swift, list can be immutable and mutable. With immutable list, it can’t be added or removed. [gist https://gist.github.com/arkilis/1cdabbd71f64cdde50637179157375b8] In Swift, the mutable and
Read More »

Optional in Swift (Easy Start with examples)

Optional in Swift Swift is designed as a type Safe language. With the introduction of Optional, Swift solved the issue that variable can be nil or not in Objective-C, which makes the code more robust and safe. Optional is like a box, you can put normal type (Int, String, object) into the box, or Optional
Read More »

Selector in Objc/Swift

In this short article you will know: Selector in Objc Selector in Swift Passing value using Selector Selector in Objc: Selector is a concept of Objective-C Runtime, which allows to turn a method’s name (NSString) into a SEL type. Basically you cand find @selectoreverywhere, such as adding a method to a view, NSNotification, etc. [gist
Read More »

iOS TableView Development Tips

The following are some frequently used iOS TableView tips while developing: Change the tableview background color: Sometimes you probably need to change the whole table view background. self.tableView.backgroundColor = colorTableview; Reload the data in Table view: After update the table data array/dictionary, you probably want to manually reload the whole table. [self.fileSelectionTableView reloadData]; Remove blank
Read More »

Delegation in Swift

Similarly, in Swift you can have Delegation: Step 1: Create a new Cocoa class, i.e WeatherService.swift, in this Swift file which include: A Protocol A Delegate Property WeatherService.swift [gist https://gist.github.com/arkilis/5158db538c985612506af43d7e9f77c8/] Step 2: Implement Delegation [gist https://gist.github.com/arkilis/83a381aeb29592e44c6dc502343176ae/] There are a couple of things have to pay attention to: As Swift support multi-inherence, which means a class
Read More »

Swift Extension and Objective-C category

Category in Objective-C, Extension in Swift are the same concept. They can help you to organise your class code. With category and extension, you don’t have to create a inherited class. Extension in Swift Step 1: Create a Swift file Then in the Swift file: [gist https://gist.github.com/arkilis/fa6abfc9eb66ed5527fc3ea5bb70ffa3 /] Step 2: Use extension: [gist https://gist.github.com/arkilis/5a622dcf50d68d656d8d58965ff7d5ca /]
Read More »

A Quick Start on Carthage

0x00: Install Carthage on you mac: brew install Carthage 0x01: Under your project root directory, vim Cartfile: Notice: == 1.0 means using version 1.0 >= 1.0 means using version 1.0 or higher ~> 1.0 means using version 1.0 but lower than version 2.0, i.e. 1.2 0x02: In your project root directory, run: carthage update --platform
Read More »

Use default iOS URL Schemes

// Make a phone call [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:12125551212"]]; // Open an url using default brower Safari [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.needone.app"]] // Send an email by calling Email app [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:arkilis@gmail.com"]]; // Send a SMS [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:0400000000" // Make a phone call UIApplication.shared.openURL(URL(string: "tel:12125551212")!) // Open an url using default brower
Read More »