Binary Tree Concepts

Basics Why height of a tree? We want to figure out the height of a tree because that is the worst case scenario of a search. It is the max number of step it takes to find an item. For example, if we find the item at the root node. Great! it took only 1 […]

MVC for iOS

MVC for iOS Data Models – objects that you use to maintain, manipulate and retrieve retrieve. The data model represents the core information that your application is being used to access and manipulate. For example, User is a piece of data. Then you would want to have a class UserDB, where you specifically have methods […]

Rotating CALayers around Y axis using Core Animation and Controlling it with Slider

ref: http://stackoverflow.com/questions/3831867/trying-to-make-a-card-from-calayers-that-can-flip-over http://www.binpress.com/tutorial/objectivec-lesson-13-keyvalue-coding/79 Setting up the Layers Basically, we have two layers. One if the front with some text. The other is ‘back’ layer with some text, in which we place underneath the front. However, you rotate the ‘back’ 180 degrees so that back’s text is facing the back. That way, when we rotate the […]

using @synchronize to solve Mutual Exclusion

ref – http://stackoverflow.com/questions/28005734/making-a-class-thread-safe-in-ios mutual exclusion refers to the requirement of ensuring that no two concurrent processes[a] are in their critical section at the same time; it is a basic requirement in concurrency control, to prevent race conditions. A race condition or race hazard is the behavior of an electronic, software or other system where the […]

dispatch_get_global_queue vs dispatch_get_main_queue

dispatch your tasks on dispatch_get_main_queue() for UI changes. The main queue is a special serial queue. Unlike other serial queues, which are uncommitted, in that they are “dating” many threads but only one at time, the main queue is “married” to the main thread and all tasks are performed on it. Jobs on the main […]

Serial vs Concurrent Queue

Concurrent vs. serial determines how submitted tasks are to be run. A concurrent queue allows the tasks to run concurrently with one another. A serial queue only allows one of its tasks to run at a time. Concurrent Queue Concurrent queues (also known as a type of global dispatch queue) execute one or more tasks […]

Threads Basics (using objective c)

ref: http://stackoverflow.com/questions/79923/what-and-where-are-the-stack-and-heap Local variables are stored in each thread’s own stack. That means that local variables are never shared between threads. The OS allocates the stack for each system-level thread when the thread is created. That also means that all local primitive variables are thread safe. For example, in objective C:

The result is: […]

Implicit vs Explicit

In computer programming, a mutex is a program object that allows multiple program threads to share the same resource, such as file access, but not simultaneously. When a program is started, a mutex is created with a unique name. IMPLICIT – implied though not plainly expressed. In other words, implied, hinted at, suggested, insinuated. IMPLICIT […]

thread safe class

http://stackoverflow.com/questions/28005734/making-a-class-thread-safe-in-ios Thread safety means that the data structure can be accessed and/or modified by multiple threads without becoming corrupt. One simple approach is to use Objective-C’s @synchronized capability. In this case, @synchronized(self.data) around all of your accesses to the array will ensure that only a single thread can access the array at a time. Even […]