Hi all. When I started with iPhone app development, back in 2009, being a developer with Java background at that time, the first question that came to my mind was: “How to program for iPhone“. Or more precisely, “How to make apps for iPhone” Keeping that in mind, I will be starting a new category here at iolearner.com. It will be exclusively for people starting to learn/develop iPhone/iPad applications. It will comprise of a series of tutorials, that will start iPhone application development from scratch.
iOS 5.0 introduced a new control that provides the user with an option to increment or decrement a value- UIStepper. So, in this tutorial, we will learn how to use UIStepper.
Let’s get started with implementing it in our project. We would require Xcode 4.2 or above for UIStepper to work, as this is supported only in iOS 5.0.
Continue Reading
Very often, we run an application and we come across a line saying, Thread n: Program received signal: “EXC_BAD_ACCESS”. And when we try to find out the line of code, the problem occurred, we aren’t able to find out.
In this tutorial, we will learn how to track the EXC_BAD_ACCESS instruction, and map it to the exact line where the error occurred.
First let’s discuss why this error occurs. We know that calling release on an object decreases its retain count by 1. And when the retain count reaches 0, dealloc is called on the object, and it is flushed from memory, leaving no traces of that object.
EXC_BAD_ACCESS occurs when we try to send a message to an object that has already been freed. In other words, if we access an object that has already been removed from the memory. And that is the reason we can’t track the exact place where the error occurred, because the object itself is not there in memory.
Continue Reading
Hi all!
iOS 5.0 has an interesting feature, called UIReferenceLibraryViewController.
According to Apple:
“A UIReferenceLibraryViewController object provides a dictionary service to look up the definition of a word or term from within an app. ”
Thus, we can look up the definition for any word, and display it to the user, but beware of one thing:
“It should not be used to display wordlists, create a standalone dictionary app, or republish the content in any form“. So lets get started with the project.
Continue Reading
Hi all, Many a times we need to show a timer in our application, to record time, to show a stop watch, or show the current time to the user of our iOS application. We can do that with the help of NSTimer. We will scrutinize NSTimer by creating a clock application, that will display the current time in a digital format, with a precision to the level of microseconds like this: 
In our previous tutorial, we had generated a pdf programmatically on iPhone. I got loads of requests for a tutorial to generate a pdf from an html file, or convert an html rendered in a UIWebView into a pdf. In this tutorial, we will convert an HTML file into a pdf.
The Steps:
We will follow the following steps to do this:
Step 1: Open the html in a UIWebView.
Step 2: Capture the web view, part by part by rendering it into an image context. In other words, we will take a snapshot of the web view, render it into an image context, and save it to our documents directory. We will then programmatically scroll the web view, again take a screenshot and save it, and repeat the process till we reach the end of the web view.
But, how to scroll the web view? UIWebView has a scroll, but it is is not a subclass of UIScrollView. Actually, it has a subview that is a UIScrollVIew. But we would require to programmatically scroll the web view. For this, we will use:
[ourWebView stringByEvaluatingJavaScriptFromString:@"window.scrollBy(valueToScroll);"]; |
Step 3: Finally, we will draw all the images we have saved into a pdf context. That’s it.
We will convert our old pdf generation tutorial html into a pdf, and this is how the final pdf will look like: Converted Html To Pdf
So let’s get started.
Continue Reading
I had an assignment where, the user was given an option to choose a color from a number of colors. And the user had an option to go back and forth between the colors he had chosen, like an Undo/Redo.
The Options:
Thus, I was left with two options:
Option 1: Save the colors the user was choosing, locally in an array and, as the user chose a different color, store it, and according to the option the user would select- Undo/Redo.
Option 2: Save the color the user chose to Sqlite through core data, and use the magical wand provided by Core Data, the Undo/Redo support, by using the NSUndoManager.
I went on with choosing Option 2, as i considered it a bit more reliable and preferred, and reuse the idea anywhere in my future assignments.