SKScene and UIViewController. Delegation and notifications in Sprite Kit.

Featured

A scene is the root node in a tree of Sprite Kit nodes. We implement our game logic there. However, there are many situations that SKScene needs to inform its view controller about some events or wants to force particular behavior only view controller can provide. This article shows how to make this communication work. And what is most important – how to do it in the cleanest possible way.
Continue reading

How to use UIGestureRecognizer to drag and drop views. iOS.

Featured

In this tutorial I will explain how to use UIPanGestureRecognizer to drag and drop views. If you want to jump straight to the code you can download a fully working example project from here.

Drag and drop view

UIPanGestureRecognizer is a subclass of UIGestureRecognizer that specialises in detecting panning (dragging) gestures. A panning gesture can have 3 states.

It begins when user touched the screen and starts dragging. In this moment UIPanGestureRecognizer‘s state changes to UIGestureRecognizerStateBegan. Then, when user continues panning, state of gesture recognizer changes to UIGestureRecognizerStateChanged. Finally, when user released the finger, the gesture ends (UIGestureRecognizerStateEnded). We will use this in our handler method to move an instance of UIView along with the panning gesture.

Let’s start creating an empty project in Xcode. I chose Single View Application template and created a view in the center of the screen.
Continue reading

All you wanted to know about NSRunLoop. iOS.

Featured

NSRunLoopThis article explains in simple words, like to a rubber duck, what a run loop is in OS X and iOS.

What is a NSRunLoop?

A run loop is an event processing loop that you use to schedule work and coordinate the receipt of incoming events. The purpose of a run loop is to keep your thread busy when there is work to do and put your thread to sleep when there is none.

That’s what docs say. Each thread, including the application’s main thread, has an associated NSRunLoop object. The app frameworks automatically set up and run the run loop on the main thread as part of the application startup process.
Continue reading

DHCP in OS X Server.

This article explains configuring DHCP in OS X Server in simple steps. It’s an easy to follow tutorial with screenshots and hints that will help you in starting a DHCP service in your network.

DHCP in OS X Server. Creating a DHCP pool.

First thing we have to do is to set up a desired IP address pool the DHCP server should use. This requires providing start and end addresses of the pool, network mask, and router (default gateway) IP address. Additionally we can also specify DNS servers’ IP addresses and lease time.

2. Creating a DHCP pool

Continue reading

Installing and configuring bluetooth dongle with Raspberry Pi.

This article explains in simple steps the process of configuring bluetooth dongle with Raspberry Pi.

Update the list of available packages.

sudo apt-get update

Install new versions of the packages.

sudo apt-get upgrade

Installing packages

Remove the redundant packages after the upgrade.

sudo apt-get autoremove

Continue reading

Introducing NSLayoutConstraint Extensions.

CollisionNSLayoutConstraint Extensions is a useful category on NSLayoutConstraint containing a set of helper methods for creating most commonly used constraints. The category also includes a debugging extension that makes troubleshooting invalid constraints much easier and faster.

It is designed to be as easy to use as possible to integrate and use to speed up everyday development tasks. All the methods are well documented and described using doxygen style. Continue reading

Dynamic linking in Java.

This article explains all you need to know to understand how dynamic linking in Java works.

Dynamic linking in Java

Java applications are typically compiled to bytecode that can run on any Java Virtual Machine (JVM) regardless of computer architecture. The bytecode is an intermediate representation, which is then, linked to platform-specific machine code.

To understand the dynamic linking we must first divide Java program execution into steps. Java language specification defines 5 of them.
Continue reading

Raspberry Pi status LEDs.

Raspberry PiRaspberry Pi boards have 2 or 5 Light Emitting Diodes (LEDs). The LEDs indicate status of the operations such as accessing the SD Card or network activity. All of the diodes are located next to the audio socket, in the corner.

The number of LEDs depends on the model. Newer boards have 5 diodes. Older ones, only 2.

Functions of the status LEDs

ACT (or OK on the older boards) - green, blinks when SD card is accessed.
PWR - red when powered on.

LEDs below exist only on Model B boards.

FDX - green when connected to Full Duplex Ethernet network.
LNK - green when Ethernet is connected, blinks on data transfer.
100 (or 10M on on the older boards) - orange, indicates 100Mbit Ethernet.

Continue reading

Detecting UILabel’s text change.

Iraqi FreedomKey-value observing is a mechanism that enables an object to be notified directly when a property of another object changes.

However, in general KVO does not work with UIKit classes. Basically, in most of the cases, they do not support it. Here is what Apple says about it:

Although the classes of the UIKit framework generally do not support KVO, you can still implement it in the custom objects of your application, including custom views. – Cocoa Core Competencies

Continue reading

Getting Twitter followers list using Social framework in iOS.

Bluebird

This article presents a useful code snippets for interacting with Twitter’s Friends & Followers REST APIs, which provide simple interfaces for most Twitter functionality.

It shows how to implement getting Twitter followers list and friends list in iOS using Social and Accounts frameworks.

Continue reading