Swift
90.0K views | +0 today
Follow

DPTransparentEdgesTableView (Swift and Objective-C implementation) for iOS - Cocoa Controls

From www.cocoacontrols.com

Table and scroll view with transparent top and bottom edges. Written in Objective-C and Swift

No comment yet.

HGWActivityButton - Swift for iOS - Cocoa Controls

From www.cocoacontrols.com

A UIButton subclass with a custom, built-in activity indicator

No comment yet.

Tutorial: Creating Great Looking Button Transitions With Core Graphics And Swift

From maniacdev.com

Back in February I mentioned an interesting library providing navigation bar buttons with slick animations between them. Here's a nice tutorial showing how to create a slick transition between two ...
No comment yet.

Tutorial: Using Generics To Implement KVO In Swift

From maniacdev.com

One of the issues you'll notice when using Swift is that native key-value-observing is not available and only works with NSObject subclasses. Swift is changing rapidly and a solution does appear to...
No comment yet.

GoogleWearAlert (Swift) for iOS - Cocoa Controls

From www.cocoacontrols.com

An Android Wear style animated confirmation view for iOS - Written in Swift

No comment yet.

UIDynamics in Swift | Big Nerd Ranch

From www.bignerdranch.com

App development training for programmers and designers, mobile development services for companies of any size, and best selling programming guides.
No comment yet.

A Minimum Viable tableView in Swift - Adoption Curve Dot Net

From adoptioncurve.net

This GitHub repo is a minimum viable implementation of a UITableView in Swift. Here’s a swift (badum, tish) tutorial on creating a UITableView …
No comment yet.

Tutorial: Facebook Login in Swift using a Bridging Header | iOS Life

From www.brianjcoleman.com

In this tutorial learn how to integrate Facebook Login into your iOS Swift project using a Bridging Header.
No comment yet.

Open Source Swift Library Simplifying Use Of NSURLSession

From maniacdev.com

A couple of weeks ago I mentioned a library providing a a nice clean syntax for working with JSON in Swift. Here's a Swift library that wraps NSURLSession providing a simplifed syntax called SwiftH...
No comment yet.

Tutorial: Post to Web Server API in Swift using NSURLConnection | iOS Life

From www.brianjcoleman.com

In this tutorial learn how to communicate with a web API from your iOS Swift project.
No comment yet.

Open Source Library Providing A Core Data Query Language For Swift

From maniacdev.com

I've mentioned a number of libraries for working with Core Data, the most popular of which being Magical Record. Here's an open source Swift based library providing a very nice syntax for querying ...
No comment yet.

Open Source iOS Component For Creating Draggable Card Style Alert Views

From maniacdev.com

Late last year I mentioned a nice library for creating custom alert views that are styled similar to the native iOS alert views, but adding in nice features such as support for images, and extra bu...
No comment yet.

• Singletons in Swift In this post, I will to...

From weblog.invasivecode.com

Singletons in Swift



In this post, I will to demonstrate one particular way of creating singletons in Swift. But, before starting, let me just say: Swift is a very powerful programming language that allows developers to construct the same functionality in multiple ways. Therefore, the following example is just one way of building a singleton in Swift.



Generally, I discourage the use of singletons, as instantiating an object that will last forever is not good design. Instead, I prefer letting ARC do the memory management and letting ARC decide when to release an object or keep it alive. Additionally, there’s always an alternative way to build what you are trying to do with a singleton.




Nonetheless, despite my recommendations, I will demonstrate a way of building a singleton or a shared object in Swift, just in case you absolutely need one.



Let’s suppose that you need a shared instance of a class Monitor to continuously monitor the status of a running algorithm in your application. The Monitor class will be a subclass of NSObject and you want to instantiate this class only once. Here’s how to build this class in Swift:



import Foundation
class Monitor : NSObject {

class func sharedMonitor() -> Monitor {
return _sharedMonitor
}

}
var _sharedMonitor: Monitor = { Monitor() }()




In the above source code, first, I imported the Foundation module to be able to subclass NSObject. Then, I created a class Monitor subclassing NSObject. The class contains a class function sharedMonitor. This function doesn’t take any input arguments and returns a class type Monitor. The _sharedMonitor variable is defined as a global variable and I initialized it to a closure that simply instantiated the Monitor class.



But, how can you use it? Well, suppose you need to reference this singleton from another object. You can write:



let monitor = Monitor.sharedMonitor()




Now, let’s build a small example. Using Xcode 6 (currently in beta), create a Single View Application and name the project Singleton. Choose Swift as the programming language and save the project wherever you like. Then, add a new class to the project. Choose iOS -> Source -> Cocoa Touch Class. Name the class Monitor and make it a subclass of NSObject. Choose Swift as the language and save the class.



Next, open the Monitor.swift file and modify it as I previously described:



import Foundation

class Monitor: NSObject {

class func sharedMonitor() -> Monitor {
return _sharedMonitor
}

}
var _sharedMonitor : Monitor = { Monitor() }()




Then, open the ViewController.swift file and in the -viewDidLoad method create two constants of type Monitor and check that they are identical:



let monitor1 = Monitor.sharedMonitor()
let monitor2 = Monitor.sharedMonitor()

if monitor1 === monitor2 {
println(
No comment yet.

Open Source Library For Easy and Clean Asynchronous Flow Control In Swift

From maniacdev.com

About a year and a half ago I mentioned a library for asynchronous flow control in Objetive-C called Sequencer. Sequencer definitely helps to make your asynchronous code more readable and clean. He...
No comment yet.

Tutorial: Creating A Candy Crush Style Game In Swift With Sprite Kit

From maniacdev.com

Apple has done an excellent job with the documenting the Swift programming language and I've been asked a couple of times about tutorials and so far by the best are on Apple's own Swift Progra...
No comment yet.

Introducing the raywenderlich.com Swift Style Guide | Ray Wenderlich

From www.raywenderlich.com

Check out the first draft of our official Swift style guide - and submit your comments!
No comment yet.

Open Source iOS Component For Creating Great Looking Custom Alert Views Made With Swift

From maniacdev.com

I've mentioned a number of custom iOS alert view components, most recently AMSmoothAlert which features a clean style and nice popping animations. Here's an open source component created with Swift...
No comment yet.

Example: Recreating The Twitter App Startup Transition In Swift With Core Animation

From maniacdev.com

Yesterday I mentioned a component allowing you to easily replicate the animated view bending effect as seen in the Skype app. Here's another project created to show how to replicate the effect of a...
No comment yet.

Tool: A Command Line Documentation Generator For Swift

From maniacdev.com

Last week I mentioned a nice library for working with JSON in Swift as using the JSON parsing API's in the iOS SDK can become tedious. Documentation generation in Swift is another issue to be tackl...
No comment yet.

PKHUD for iOS - Cocoa Controls

From www.cocoacontrols.com

A Swift based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8.

No comment yet.