All Posts

Using threads for a JSON request

Tweet Make sure you have JSON Framework installed first. This is a continuation of Post JSON to a webservice So if you are writting your webservice application and you have to wait a few seconds to make the request and get the response you will notice that your main application gets locked up. This is due to having to wait for the request to complete and nothing else can work till that request is completed.

UIBarButtonItem with a custom view

Tweet The main project I am doing for Photoblog is an application to show all the latest entries and such. So I call a web service using JSON and it gives me the data I need. Now there might be a few second delay in sending the request and getting the request back. Once I get the request back I open my new view. So one way to show the user that activity is going on is creating a activity indicator.

UIImageView in a custom cell

Tweet Make sure you have JSON Framework installed first. This is a continuation of Click a Cell So there has been some requests to do this. If you want to display a image in a custom cell it is pretty easy. It is about the same as doing the title and the URL to the image we did before. This will take over where click a cell left off. So you can grab the source code from there and start.

Append to a NSString

Tweet I was working on appending to some strings and there is a way to do it with NSString but you are better off working with NSMutableString instead. I have a feeling doing it with NSString, if not done correctly, will leak memory. NSMutableString *hello = [[NSMutableString alloc] initWithString:@"Hello"]; [hello appendString:@" World"];

Click a Cell

Tweet Make sure you have JSON Framework installed first. This is a continuation of JSON Error So here is a quick tutorial on how to click on a cell and load some JSON data for that cell. So the idea is you have a unique ID for each set of data you have. So for that I am going to change the php code to add a ID <php header('Content-type: application/x-json'); $id = (int)$_GET['id']; $array = array( 1 => array( 'id' => 1, // added this 'title' => 'Brown Dog', 'img' => 'http://iphone.

Using NSUserDefaults

Tweet This will go over a quick run through of using NSUserDefaults. This is the class to use to save user preferences for example. It is pretty straight forward. Saving Data This is how you save data. NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; // saving a string [prefs setObject:@"test" forKey:@"stringVal"]; // saving a int [prefs setObject::23 forKey:@"intVal"]; // saving it all [prefs synchronize]; Loading Data NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; // getting the string stringVal = [prefs stringForKey:@"stringVal"]; // getting the int intVal = [prefs integerForKey:@"intVal"]; That is it.

Create a text input

Tweet So here is a quick no real code tutorial. This is another thing that took me a bit to figure out. For this example, I am putting a text input in a TableView. So here is my class declaration. @interface OptionsViewController : UITableViewController <UITextFieldDelegate> { } You need to put the UITextFieldDelegate as a reference class. Now I am going to create the text input in the .

Add a navigation button

Tweet This will pickup where Create a view left off. So you can pick it up from there and download the source. You probably don’t even need the source but grab it if you wish Now when you create a new view, in that view you might want to place a button in the navigation bar. This is pretty easy to do. So you want to open up the sub-view controller.

First JSON Iphone application

Tweet So now that we have the basics of installing JSON to our project, lets make a test application. I started by creating a new project and used the Navigation Controller Template. The first thing you want to do is setup your JSON environment as explained in the previous post and again you can visit the link above for instructions on how to do that. Once it is setup you are ready to code.

Custom UITableViewCell

Tweet Make sure you have JSON Framework installed first. This is a continuation of More Complex JSON endpoint The reason why OOP is so powerful is that you can subclass everything to make it work or look just how you want it. The default look of a UITableViewCell is just one line of text. If you want to add some text below it you need to subclass that. So that is what we will do right now.