How to use Swift code in Objective-C

Apple told you about it, but not very clean. The process is actually pretty simple.

Xcode generates a header file for all your Swift code in the project, so you can use it in Objective-C. Yes, if you have multiple Swift files in your project, you shouldn’t think about what file you need to import — it’s just one for all Swift code. The file name of this header is "ModuleName-Swift.h". And we’ll set it up now in a few steps. Continue reading

How to create custom cells for UICollectionView using Swift

Let’s continue our journey through the UICollectionView class. Creating cells for UICollectionView is really easy, moreover you can use the same approach for UITableView. Let’s take a look at how to do it using Swift.

You will learn how to create simple cells with text and images in them, how to handle taps, and at the end of the article I’ll talk about how to use a xib file to create a cell.

In this tutorial I presume that you’ve already finished my previous tutorial — How to create UICollectionView using Swift without storyboards, because here I’ll use our finished Xcode project. If you didn’t, then don’t worry, the only thing you need here is working UICollectionView. Continue reading

How to import a 3rd party framework into a Swift project

One day you’ll need to set up, let’s say, a mobile analytics system or a crash reports sender in your app. They are all useful, but some of them require you to import their framework into your Xcode project. Problem is, they’re now all written not using Swift Programming Language. In this little article I’ll tell you how to properly import a framework into your project. Continue reading

SyntaxHighlighter Evolved: Swift Brush released

This simple WordPress plugin adds support for the Swift Programming Language to the SyntaxHighlighter Evolved plugin.
Requires SyntaxHighlighter Evolved plugin to be installed first.

I admit that I may have missed some Swift keywords or something, so if you find it, please tell me about it. Thank you.

Example code

@objc
class ExampleClass {

    let text: String
    var num = 0

    init(text: String) {
        self.text = text
        println("Text = " + text)
    }

    func incrementNum() {
        num++
    }
}

Installation Instructions

  1. Upload syntaxhighlighter-swift to the /wp-content/plugins/ directory.
  2. Activate the plugin through the Plugins menu in WordPress.

How to use

Simply wrap your code in tags or . You may want to take a look at more tags that you can use on SyntaxHighlighter Evolved settings page.

Download now from here.

Movieday 2 update released

In this this version I’ve completely redesigned Movieday to make it easier to control the calendar and explore new movies. And finally you can mark movies as watched. Full list of changes below:

  • Add movies to the calendar as watched or planned to watch. Mark movies as watched.
  • Get lists of all watched or overdue movies with just one tap.
  • Improved and unified search. Get search results from the Internet by people and movies, and also by movies from the calendar.
  • Temporarily removed upcoming movies.
  • Removed companies from search.
  • Removed bookmarks.

How to create UICollectionView using Swift without storyboards

There’s a lot of tutorials about how to create a UICollectionView using storyboards or just nib files. I don’t like Interface Builder and prefer to do everything in code. Most of the time it’s easier, it creates less bugs, so in this tutorial we will create UICollectionView programmatically.

UICollectionView is highly customizable class for presenting your content in almost any layout you want. If you want Apple to tell you basics about it, visit WWDC 2012 videos “Introducing Collection Views” and “Advanced Collection Views and Building Custom Layouts”. It implements in a similar way to UITableView — using UICollectionViewDataSource and UICollectionViewDelegate protocols. Let’s take a look at how to do it using Swift. Continue reading