Archive for September, 2009
Saving NSMutableArrays
Good day lads and lasses of the internet, I decided that saving data files for your applications is an important one to know and saving objects in an NSMutableArray wants you to occasionally make you gouge your eyes out until you get the system lined up pretty well. Let us start with the order of events here for saving and loading. Create and NSMutableArray with your object -> Locate the directory and the file to save to -> Encode the array into an NSMutableData file -> Store the NSMD in the given directory Simple enough. For loading, its really the same system just backward I guess you could say. We’ll go into that a little bit later. For now, Open Xcode -> New Project -> “View Based Application” -> “New File” -> “Objective-C Class” -> Call it theFile and check the box for a header file. At this point, I am going to expect you all to know how to do some of these remedial tasks. Go to your header for this new file and declare two NSStrings along with their @property/@synthesize declarations at the end of the header and start of the @implementation. This is the object that we are going to toss into our NSSMutableArray later, which means we are going to have to conform to some protocols designated by the foundation framework. Let us assume you called your two NSStrings textField and numberField (mainly because that is how I named them in the sample code, there are a few treats in there that use styles and all for text fields etc that weren’t mentioned before). We will need to implement both the encoder and decoder methods here and thats it. Add the following code to the implementation of theFile:
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeObject:textField forKey:@"text"];
[encoder encodeObject:numberField forKey:@"number"];
}
-(void)initWithCoder:(NSCoder *)coder {
textField = [[coder decodeObjectForKey:@"text"] retain];
numberField = [[coder decodeObjectForKey:@"number"] retain];
}
First off is the encode protocol, all we are doing here is encoding the two strings inside of the theFile and giving them a reference string so that we can locate them later. The other method does the opposite of that, it decodes both objects for the given keys and stores them in those strings. With that, we can move on to the quick user interface I wrote for this. We are going to want two UITextFields to control the content of the strings in our custom object, two UIButtons to save and load the data, and a UILabel to display the loaded contents. Same thing as we did in our previous tutorial that introduced our world of iDevKit to the UITextField, UILabel, and UIButton, which can be found here. I will give you the set up code here for all the UI today but this will probably be the last time until something new is tutorialized. Add the UITextFields to the header of your viewController class (labelField, numberFieldUIButtons (saveItems, loadItemstheFile *value;.
- (void)loadView {
CGRect frame = [UIScreen mainScreen].applicationFrame;
UIView *view = [[UIView alloc] initWithFrame:frame];
self.view = view;
displayLoad = [[UILabel alloc] initWithFrame:CGRectMake(10,140,300,28)];
displayLoad.font = [UIFont fontWithName:@"Arial" size:16];
[self saveItems];
[self loadItems];
[self labelField];
[self numberField];
[self.view addSubview:saveItems];
[self.view addSubview:loadItems];
[self.view addSubview:labelField];
[self.view addSubview:numberField];
[self.view addSubview:displayLoad];
}
-(UIButton *)saveItems {
saveItems = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
saveItems.frame = CGRectMake(50,222,90,45);
[saveItems setTitle:@"Save" forState:UIControlStateNormal];
[saveItems setTitle:@"Save" forState:UIControlStateHighlighted];
[saveItems setTitleColor:[UIColor colorWithRed:0.0 green:0.3 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
[saveItems setTitleColor:[UIColor colorWithRed:0.0 green:0.1 blue:1.0 alpha:1.0] forState:UIControlStateHighlighted];
[saveItems setBackgroundColor:[UIColor clearColor]];
[saveItems addTarget:self action:@selector(saveObjects) forControlEvents:UIControlEventTouchUpInside];
return saveItems;
}
-(UIButton *)loadItems {
loadItems = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
loadItems.frame = CGRectMake(180,222,90,45);
[loadItems setTitle:@"Load" forState:UIControlStateNormal];
[loadItems setTitle:@"Load" forState:UIControlStateHighlighted];
[loadItems setTitleColor:[UIColor colorWithRed:0.0 green:0.3 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
[loadItems setTitleColor:[UIColor colorWithRed:0.0 green:0.1 blue:1.0 alpha:1.0] forState:UIControlStateHighlighted];
[loadItems setBackgroundColor:[UIColor clearColor]];
[loadItems addTarget:self action:@selector(loadObjects) forControlEvents:UIControlEventTouchUpInside];
return loadItems;
}
-(UITextField *)labelField {
if (labelField == nil) {
CGRect frame = CGRectMake(20,100,280,30);
labelField = [[UITextField alloc] initWithFrame:frame];
labelField.borderStyle = UITextBorderStyleRoundedRect;
labelField.textColor = [UIColor blackColor];
labelField.font = [UIFont systemFontOfSize:17.0];
labelField.placeholder = @"Type Something...";
labelField.backgroundColor = [UIColor clearColor];
labelField.autocorrectionType = UITextAutocorrectionTypeNo;
labelField.keyboardType = UIKeyboardTypeDefault;
labelField.returnKeyType = UIReturnKeyDone;
labelField.clearButtonMode = UITextFieldViewModeWhileEditing;
labelField.tag = 1;
labelField.delegate = self;
}
return labelField;
}
-(UITextField *)numberField {
if (numberField == nil) {
CGRect frame = CGRectMake(20,50,280,30);
numberField = [[UITextField alloc] initWithFrame:frame];
numberField.borderStyle = UITextBorderStyleRoundedRect;
numberField.textColor = [UIColor blackColor];
numberField.font = [UIFont systemFontOfSize:17.0];
numberField.placeholder = @"Numbers...";
numberField.backgroundColor = [UIColor clearColor];
numberField.autocorrectionType = UITextAutocorrectionTypeNo;
numberField.keyboardType = UIKeyboardTypeNumberPad;
numberField.returnKeyType = UIReturnKeyDone;
numberField.clearButtonMode = UITextFieldViewModeWhileEditing;
numberField.tag = 1;
numberField.delegate = self;
}
return numberField;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
Not going to reinvent the wheel here so if you have any questions, consult the project I attach to the end of this or previous tutorials, there is NOTHING NEW. Alrighty then, notice that the UIButtons send us to two separate methods: saveObjects and loadObjects. Let us start with saving:
-(void)saveObjects {
value = [[theFile alloc] init];
value.textField = labelField.text;
value.numberField = numberField.text;
NSMutableArray *array = [NSMutableArray arrayWithObjects:value,nil];
NSMutableData *data = [NSMutableData data];
NSKeyedArchiver *encode = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [path objectAtIndex:0];
NSString *file = [docDirectory stringByAppendingPathComponent:@"save.iDK"];
NSLog(file);
[encode encodeObject:array forKey:@"save"];
[encode finishEncoding];
[data writeToFile:file atomically:YES];
[encode release];
}
Okay then… First three lines are going to allocate/initialize an instance of theFile and set both of the strings inside of it to the values set in our UITextFields. After that, we create an NSMutableArray and store value inside of it, where nil denotes the end of the array. We then create a data file that will later house our array, we use NSMutableData for this. Then we declare an NSKeyedArchiver that will be used in encoding our data file. Now comes a really important step: locating our save directory. This part I just kind of pulled as stock code from Apple but I will do my best to tell you what is going on. The first line there finds us our local path to our app, then it finds the contained Documents directory. We then extract the string from the array that will then be used to place our fileNSLog() here so we can find our application directory for the simulator if we are so inclined. Few more steps: we encode our NSMA and to a reference point for later and push the encoding along. After that, we write the data to our file, clean memory, and we are saved! Almost done, now to add in our decoder bit, add our loadObjects method and lets begin.
-(void)loadObjects {
NSFileManager *manager = [NSFileManager defaultManager];
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [path objectAtIndex:0];
NSString *file = [docDirectory stringByAppendingPathComponent:@"save.iDK"];
if([manager fileExistsAtPath:file]) {
NSLog(@"file located and reading");
NSMutableData *data;
NSMutableArray *array;
NSKeyedUnarchiver *decode;
NSString *label;
if(!value) value = [[theFile alloc] init];
data = [NSData dataWithContentsOfFile:file];
decode = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
array = [decode decodeObjectForKey:@"save"];
[decode finishDecoding];
[decode release];
value = [array objectAtIndex:0];
label = value.textField;
label = [label stringByAppendingString:value.numberField];
displayLoad.text = label;
} else {
NSLog(@"file not found, save something to create the file");
}
}
First up is we create what is called an NSFileManager and we set the value of this instance to defaultManager; in a nutshell, this is just creating an object that we will later use to look for a file and return a boolean value on whether or not it exists. After that we do like we did before in the saving method and locate our file’s directory and name (not to be confused with the file itself, this just tells the device where the file SHOULD exist and what it SHOULD be called if it does exist). Now we use a simple if-else statement that uses our manager to check to see if our file located at file exists, and if so, it will load it, if not, it sends an error message to the console and ends the method. Let us assume it exists, otherwise its just boring and you won’t learn anything. To start with we will declare the same variables we did while saving, with exception to the NSKeyedArchiver, which we replaced with the inverse: NSKeyedUnarchiver. We also put in an NSString to store the displayed string in later. The next line checks to see whether or not we have already allocated value, and if not, then we allocate it, simple ’nuff. We now pull the NSMutableData file from our Documents directory that we proved existed, and store it in data. We decode the data file from there using our unarchiver and search for an NSMutableArray inside it using the key that we archived with before. We push the decoder along while we store the array in array, clean the memory a little, and pull the first value from the array and store it in value. From here is all cosmetic, we take the two strings in our new object, combine them, and set the UILabel text to it.

Thats about it, if you have any questions just ask, you can find the source code here.


Regards,
Sj
UITextFields and UIButtons
Hi again everyone, sorry for the late update, I have been pretty busy with another project for the blog this past week, along with a few other jobs/projects unrelated to this. I still have yet to finish that other tutorial so I thought I would throw something together today that most of you guys will find relatively helpful (I hope). So here we have it, a little tutorial that covers labels (nothing new at all here), textfields, buttons, and NSUserDefaults. Alright, lets begin, open Xcode and create a new View Based Application, name it TextInput.
Navigate to TextInputViewController.h and you will need to declare the UITextFieldDelegate protocol by adding <UITextFieldDelegate> after TextInputViewController : UIViewController, this will tell your program that it needs to conform to the UITextFieldDelegate protocol, which in turn, allows you to create UITextFields. Now, in the @interface section, declare two UILabels, two UITextFields, and two UIButtons like so:
UILabel *firstLbl; UILabel *lastLbl; UITextField *firstName; UITextField *lastName; UIButton *saveBtn; UIButton *loadBtn;,
Under that, make sure to add the following code outside of the brackets but before the @end, this will let you control the UIButtons and UITextFields:
@property(nonatomic,retain) UITextField *firstName; @property(nonatomic,retain) UITextField *lastName; @property(nonatomic,retain) UIButton *saveBtn; @property(nonatomic,retain) UIButton *loadBtn;
Now, go to your TextInputViewController.m and uncomment the loadView method. Create a UIView now to fit the frame of the screen and set it to the self.view:
CGRect frame = [UIScreen mainScreen].applicationFrame; UIView *view = [[UIView alloc] initWithFrame:frame]; self.view = view;
NOTE: This is the last time I will be explaining how to create the viewController’s main view, same goes with generic labels that we will be using a lot, which will follow
From here, we need to prepare and initialize all of your views and objects that we will be using in the main viewController. Starting with the labels:
firstLbl = [[UILabel alloc] initWithFrame:CGRectMake(20,10,320,32)]; lastLbl = [[UILabel alloc] initWithFrame:CGRectMake(20,70,320,32)]; firstLbl.backgroundColor = [UIColor clearColor]; lastLbl.backgroundColor = [UIColor clearColor];
This is simple, we are preparing the UILabels for the loaded data that we will be accessing later. I didn’t bother setting any other properties for these labels, this isn’t a UILabel tutorial, I covered more of that in the Hello World tutorial a couple of weeks ago. After that, we get into the new stuff, the fun stuff. You will need to start by creating a method that looks something like this:
- (UITextField *) firstName {
if(firstName == nil) {
CGRect frame = CGRectMake(20,40,280,30);
firstName = [[UITextField alloc] initWithFrame:frame];
firstName.borderStyle = UITextBorderStyleRoundedRect;
firstName.textColor = [UIColor blackColor];
firstName.font = [UIFont systemFontOfSize:17.0];
firstName.placeholder = @"First Name...";
firstName.autocorrectionType = UITextAutoCorrectionTypeNo;
firstName.keyboardType = UIKeyboardTypeDefault;
firstName.returnKeyType = UIReturnKeyDone;
firstName.clearButtonMode = UITextFieldViewModeWhileEditing;
firstName.delegate = self;
}
return firstName;
}
Alright, there are a LOT of new concepts here, all of which pertaining to setting up your customized UITextField, we will be using this again in a moment. First off, we have an if statement that checks to see if the text field has already been allocated and initialized, if the firstName returns a nil value, then the enclosed statements are executed, if it doesn’t, then it just returns the already allocated UITextField. Assuming that the statement was satisfied, lets step through all of the properties of the text field. Like with most of the UIKit objects, you need to set the text field inside of a frame using the CGRectMake method. We initialize firstName with this frame. Then we set the borderStyle, this is what the frame of the field will look like, I used the UITextBorderStyleRoundedRect style here, which, like it says, makes the frame rounded on the corners. textColor sets the input text’s color and font sets the font size of that input, similar to that used in a UILabel. We use placeholder to fill the UITextField with a background text until it is touched and/or has any input. autocorrectionType sets whether or not to use the iPhone’s auto-correct dictionary with input, I set this to no for proof and practice, the default is YES. The keyboardType and returnKeyType properties delegate the keyboard settings, the first sets it to the standard keyboard and the latter sets the return key to say Done and to dismiss the keyboard. Almost done, clearButtonMode property tells us whether or not to use the little gray ‘X’ that clears the field. Finally, delegate tells the text field that it is being controlled by this particular view controller. We return the UITextField now at the end.
We use this method form again for the lastName, replacing firstName with lastName and changing any properties based on what you want to play with. Remember, hit Esc on your keyboard to list the available options for each property after the ‘=’ sign.
Add the following code to dismiss the keyboard when Done is clicked:
- (BOOL) textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
Now we need to start setting up the buttons that save and load the data:
- (UIButton *) saveBtn {
saveBtn = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
saveBtn.frame = CGRectMake(0,0,90,45);
[saveBtn setTitle:@"Save" forState:UIControlStateNormal];
[saveBtn setTitle:@"Save" forState:UIControlStateHighlighted];
[saveBtn setTitleColor:[UIColor colorWithRed:0.0 green:0.3 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
[saveBtn setTitleColor:[UIColor colorWithRed:0.0 green:0.1 blue:1.0 alpha:1.0] forState:UIControlStateHighlighted];
[saveBtn setBackgroundColor:[UIColor clearColor]];
[saveBtn addTarget:self action:@selector(saveText) forControlEvents:UIControlEventTouchUpInside];
return saveBtn;
}
Alrighty then, same idea as the UITextField method, we are just setting a group of properties for the UIButton. First we set the type of button we want to UIButtonTypeRoundedRect and retain the view. Next is the frame as always, the x,y coordinates are set to 0 because frankly, I prefer to set the location of UIButtons using the center point, which I will show later. Button’s titles and images etc are based off of the UIControlState of the button. First, we set the title of the button at its UIControlStateNormal, in this case it just says “Save”; we use the same statement again below, except using UIControlStateHighlighted, this sets the title of the button when it is clicked down. We set the titleColor now for both states to a custom UIColor value, followed by the backgroundColor property, which makes the outside of the frame meld with the background’s color or image. Finally, the most important bit of code is the addTarget:action:forControlEvents: that tells the program to execute the method saveText inside of self when the user performs a UIControlEventTouchUpInside, aka a touch of the button. We return the button and continue.
Do this again with loadBtn, only this time make sure to change that second to last line to:
[loadBtn addTarget:self action:@selector(loadText) forControlEvents:UIControlEventTouchUpInside];
Configure it how ever you wish and play around with the properties, the best way to learn how to program is trial by error.
Now before we put this all together in our loadView method, we have two more bits of code to write, and these will be the ones the let us save and load our data: saveText and loadText. Let us start with the first one, insert the following code after the UITextField and UIButton methods:
[[NSUserDefaults standardUserDefaults] setObject:firstName.text forKey:@"firstName"]; [[NSUserDefaults standardUserDefaults] setObject:lastName.text forKey:@"lastName"]; [[NSUserDefaults standardUserDefaults] synchronize]; firstName.text = @""; lastName.text = @"";
Alright, new concept here: NSUserDefaults. This is the Foundation Frameworks method of saving the default settings for a program along with other bits of data. The first two methods are essentially identical, you start by calling standarUserdefaults which tells the next commands to look in the standard library of saved data. Next, we need to save the string from the UITextField, which is done by using setObject: and then the string, which is the text property of your text field, and finally, we need to tell the computer where exactly to look when we want to load this, so we set forKey: to the name of the variable. NOTE: I usually do it this way as an organizational method but you can set the forKey to whatever you want. Also, if you poke around through the documentation from Apple, you can get the methods to save other types of data. Last new bit of code here is the synchronize method, which tells the program to pretty much save and do so now. If you do not use this, when you are saving larger bits of data there is a chance that it does not save before the application is exited, at which point you can lose an entire saved game, as was the case with an error I was having on an application I wrote a while back. Nothing new after that, these two calls just clear the text fields, I used this as a little visual aid to indicate that something actually happened.
Okay, almost done… now we just need to tell the program just how to load the data that we previously saved. Add:
NSString *first = [[NSString alloc] initWithString:[[NSUserDefaults standardUserDefaults] objectForKey:@"firstName"]; NSString *last = [[NSString alloc] initWithString:[[NSUserDefaults standardUserDefaults] objectForKey:@"lastName"]; firstLbl.text = first; lastLbl.text = last; [first release]; [last release];
Alright, just the normal NSString declartaion/allocation/initialization is used here, we all know how to use that, the new part comes with the string that we are initializing the variable with. We do as we did before and tell NSUserDefaults to use the standardUserDefaults, then we tell it to load the object that has a matching key to the one we put after objectForKey, if there is an object there, it loads it, if not, nothing happens, simple as that. We do the same thing again only loading a different object this time. NOTE: I am relatively sure that you can use stringForKey: instead although I have never had a reason to so play with it as you will. Now we place those strings inside of the UILabels, release the retained memory from the strings and move on to the last little thing, putting it all in play. Back to the loadView method, insert:
[self firstName]; [self lastName]; [self saveBtn]; [self loadBtn]; [saveBtn setCenter:CGPointMake(100,200)]; [loadBtn setCenter:CGPointMake(220,200)]; [self.view addSubview:firstName]; [self.view addSubview:lastName]; [self.view addSubview:saveBtn]; [self.view addSubview:loadBtn]; [self.view addSubview:firstLbl]; [self.view addSubview:lastLbl];
This is what makes everything activate and come alive. The first 4 lines execute your button and text field methods that initialze and allocate them with your custom settings. The following two set the center of the buttons to exactly where I want them, I find this easier for most subviews. The last 6 lines add everything to the superview. That is it, make sure that you release everything that you retained in the dealloc method, Build & Go.

I changed the background color the same way we did in Hello World
That is all for now, you can get the sample code here.
Regards,
sj
Apple’s Rock and Roll Event
Apple announced all the new iPod and iTunes updates today, there was a lot to see but at the same time there were a few disappointments for the iPod development community.
iTunes 9
- Genius feature updated
- iTunes LP, this is the new iTunes metadata interaction, it contains lyrics, large images, chronology etc.
- Updated artist pages in the iTunes Store
- Interactive iPhone/iPod Touch layout editor
iPod Touch (no camera)
- Price dropped, most likely for the coming holiday season
- 8GB ($199) 32GB ($299) 64GB ($399)
iPod Nano
- New device, this one will contain, get this, a VIDEO CAMERA
- Anodized steel models, shipping today
iPod Shuffle
- Price drops for everything, 2GB ($59) 4GB ($79)
- Stainless Steel 4GB model for $99
- Shipping TODAY
iPod Classic
- Price cuts, starting today
Overall, not that much to celebrate, all that is notable is the Nano 5G and iTunes 9, which Jobs stated was just a “cleaner” version of iTunes 8 with a few tweaks.
iDevKit
September 9th Event
As we all know by now, the rumor is that Apple will be making some big announcements tomorrow. Word is that we may be looking at a new line of iPods, some new iTunes toys including possibly even iTunes 9. There could easily be some big news tomorrow so iDevKit will be posting updates as soon as they are released, stay tuned. I will post more up as I find out exactly what’s going on.
Regards,
sj
UPDATE: Event info is now available: iDevKit – Apple’s Rock and Roll Event
Jailbreaking Your Device
Ok, so, this site isn’t all just the happy-go-lucky-appstore-politcally-correct-lolipops that a lot of blogs are nowadays. We find that it is really important to show the other side of development. MobileSubstrate plugins like Winterboard and Mobile Terminal, the “violators” of Apple’s ToS like MxTube, Skype, and NES Emulator. The truth is, Cydia is booming, there is a large number of applications out there that let you do anything you could ever imagine, 3G Unresticter, Ultrasn0w, and Class-Dump. So tonight, we are going to start at the VERY basic step, of jailbreaking your device with Redsn0w 0.8 and Pwnage Tool 3.01 from the iPhone Dev Team. As unexciting as it may be, it is a crucial step and one that you need to get down, I can garuntee you that you will do it more the once and most likely using a variety of methods as firmwares upgrade and change, I have jailbroken my device probably 20 something times this year.
Redsn0w 0.8 (Mac OS X, Windows, Linux)
Alright, so I use 2 laptops (both WinXP/Mac OS X Hackint0sh) and a desktop (currently flailing to turn on), and I have jailbroken iPods and iPhones with both Mac and Win, and the one thing I have realized (after gathering images for this tutorial for Win) is that it is THE EXACT SAME USER INTERFACE FOR ALL OS VERSIONS. So we are not going to bother telling you how to do the exact same thing for all OSes, I will step you through how to do it on Win, and you can adapt that to either of the other two systems (I haven’t really gotten a chance to look at Linux UI but from what I have heard it is the same). Here is what you are going to need:
iPhone/iPod Touch 3.0 IPSW File
Redsn0w 0.8 which you can get here
Once both of these are downloaded, decompress, (Linux & OS X: Mount the disk image first) and open the file labeled redsn0w (.pkg for OS X, .exe for Win, I am not too sure on the Linux extension), and a window similar to the following will appear:

Initial Redsn0w View
Click Browse and navigate to the iPhone/iPod Touch IPSW file and select Ok. You will need to be online for this step if memory serves. Redsn0w will now check the firmware file and make sure that it is valid, this can take a moment. Click Next and the program will then prepare the jailbreak data and so on.

Loading. . .
You will then be prompted with which of these you want to install.

Icy causes problems with Cydia
Click Next and make sure you follow it exactly, the following step will require that you are careful and pay CLOSE attention to the instructions on the page.

Pay Attention Now. . .
Plug your device in, turn it off, and read the next step at least three times before going any further.

PAY ATTENTION TO THIS STEP
Ok, here’s the deal, you will need to follow these steps down to the second:
-Hold the Power Button (button on top of the device) for 3 Seconds
-Click and hold the Home button for 10 Seconds WITHOUT RELEASING THE POWER BUTTON
-Now let go of the Power Button and hold the Home Button for 30 Seconds, usually redsn0w cuts this off after about 10 seconds
These steps will place the device in DFU mode, allowing the program to install the jailbreak data. Redsn0w will now begin loading the neccesary data, and you will see the following:

Installing crack. . .
Your iPhone/iPod will also display an image of a hardrive that says it is loading the jailbreak data or something along those lines. After redsn0w is done installing the crack, you will get a Finished Installing notification and be prompted to exit the program. Your device will continue patching the device from the inside and then reboot itself. If all went well, the Cydia logo will now appear on the homescreen of your device.

Open Cydia, you will get an alert that asks which packages you would like to have access to, something like: Normal User, Hacker, and Developer; select whichever one is most appropriate for what you plan on using it for, this can be changed later.

Cydia Home Screen
Cydia will respring your device and then you can open it again and your done! Go forth and play around, peruse the Cydia Store, download some fun tools and enjoy.
Pwnage Tool 3.0.1
Next utility, this one is for OS X only, and can be downloaded here. You will also need the appropriate firmware IPSW saved to your hard drive too. This tool is surprisingly straight forward to use, it is UI intensive fortunately and needs little explanation, so I will guide you as necesary but you should be fine.
Mount. Open. Run Pwnage Tool.

Select your device, the 3GS is unsupported if I am correct (let me know if I am mistaken). Also select "Expert" or "Simple" mode

The program will locate the appropriate IPSW on the hard drive

This is the customizeable stage of the program
Ok, quick interruption, General contains information regarding partition size, phone activation, baseband etc for iPhone users, Bootneuter lets you adjust baseband crack settings, Cydia packages contains a list of sources for repositories used by Cydia, Custom packages lets you select which packages (Cydia and Icy(avoid Icy the best you can, it won’t let you use Cydia apps a lot of the time)) you want to install, Custom logos lets you select the boot logo and restore screen for your device, you can select your own image as opposed to the pwnapple. After you have set everything you want and don’t want, click Build and let the program do its thing, it will ask you for your system password, just input it and the program will continue. It will then inform you that you have completed construction of a brand new “Custom” firmware for your device, you can either follow a guided process to install it or you can simply restore it via iTunes, lets do that. Open iTunes.
Option-Click “Restore” in your device’s page and navigate to your custom firmware. Select it and click Ok. iTunes will now restore your iPhone/iPod with your personal firmware. Once the device has reset, iTunes will recognize it again and allow you to activate it. Once you get to the home screen, you will see Cydia (and Icy if you’re into that). Your device is now jailbroken, congratulations.
That is all for now, look forward to some MobileSubstrate plugin tutorials soon hopefully.
Regards,
sj
Xcode and the iPhone SDK
Alright everyone, for the first tutorial on iDevKit, I though we should start somewhere relatively basic, and seeing as how this blog is going to be covering everything from Archiving to OpenGL, Quartz to GameKit, and CoreLocation to Cocoa Touch, I thought it would be best to start somewhere simple. That is why this post will cover the hows and whys of Xcode, the IDE for the iPhone and Mac OS X, and make your very own “Hello World” using Objective-C.

To start with, you will need the iPhone SDK (Xcode), available here. Download the latest version, which is currently 3.0 for unregistered users, and 3.1 beta3 for certified developers (To become a certified developer, you have to enroll with the Apple Developer Connection’s iPhone program. I will cover some hurdles related to this in a later post). After you have downloaded the SDK, mount the dmg file and install. (This part is fairly straight forward)
After you have installed the iPhone SDK, open Xcode and select File -> New Project.

Project Types

File Name
When you’re there, you will be prompted with an array of options and templates to choose from for both Mac OS X and iPhone OS. You will see six different options, but for this particular example, we will only concern ourselves with “View-Based Application”. Select View-based Application and click Choose. . ., name your project “Hello World”, and a new window will then open, containing your application template.

New Project in Xcode
Here, you’re going to see many different file references and directories. I’ll quickly go over what’s important:
Classes – In here you will find your application delegate and root view controller, with appropriate headers.
Other Sources – This contains the .pch (project header) that imports UIKit and Foundation Frameworks, along with the main.m file.
Resources – As of now, this contains the XIB files (for Interface Builder), and the HelloWorld-Info.plist. XIBs are static files used to create UIViewControllers. The Info plist contains the core settings of your application like icon location, opening orientation, Bundle Names, Identifiers, etc. Much of this is used by Apple when releasing your application on App Store via iTunesConnect (much on this “fun” process later)
Frameworks – This contains references to dynamic frameworks, including UIKit, Foundation, and CoreGraphics, with many more available on your system from the SDK. This is also where static frameworks are stored, these frameworks are compiled into your application vs being linked to a dynamic framework present on the device.
Products – This contains the executable .app that you get after compilation.
Everything else listed here is either organization, compiling information, or other components that we will worry about in the future.
For now, we are going to concern ourselves with the Classes section only. We will be using an NSString to store text, a UILabel to display the string of text, and colored background. So let us begin by editing the HelloWorldAppDelegate.m, insert the following line of code at the start of the applicationDidFinishLaunching: method:
[window setBackgroundColor:[UIColor blueColor]];
This will make the background of your application blue as opposed to the boring default white. There is a host of preset colors in the UIColor API, along with methods that let you create your own by setting the RGB properties.
Now go to your HelloWorldViewController.m file and navigate to the loadView method and uncomment it. This method will contain the code that loads your UILabel, NSString, and UIView. Insert the following:
CGRect appFrame = [UIScreen mainScreen].applicationFrame;
UIView *view = [[UIView alloc] initWithFrame:appFrame];
self.view = view;
Okay, let me explain: appframe is essentially just a rectangle the size of your device screen (320px by 480px), which is used by view to set the frame it is built around. view then becomes the layer that the rest of the ViewController uses to display other “subviews” (like UIImageView, UILabel, UIButton etc). Now we are going to add our NSString (the object that will contain our text for the UILabel). Below what we just added, type the following:
NSString *hello_text = [NSString stringWithFormat:@"Hello, World!"];
This line creates and initializes the object hello_text with the text that we will be using next. Now type below this:
UILabel *hello_label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,200,30)];
[hello_label setFont:[UIFont fontWithName:@"Arial" size:30]];
[hello_label setCenter:CGPointMake(160,100)];
[hello_label setText:hello_text];
[hello_label setTextColor:[UIColor redColor]];
[hello_label setBackgroundColor:[UIColor clearColor]];
Alright, there’s a lot here so lets break it down, starting with the first line. This line basically allocates memory for hello_label and creates a CGRect for whatever we place inside of it. Next, we set the UIFont properties for the label (for a list of available fonts, look at the end of the post) including the font itself (Arial) and the size (in px) of it (30). After that, we position hello_label’s center point so that it won’t appear at the default (0,0), but instead at our own custom position (160,100) (this is 160 px from the left, and 100 px from the top; think cartesian plain, quadrant IV). We then set the string that we want to display, in this case we are using the contents of hello_text, this is done by just using the setText: property. After that, all we are doing is setting the color of the text and the background of the frame using UIColor again. Notice something weird about the background color? Instead of setting a visible color, we use a clearColor, which is essentially just transparency. All that is left to do now is add the UILabel to our view and we can call it a day.
[self.view addSubview:hello_label];
This takes the object that we defined, and adds it to the superview. Build & Go.

Output
That is about it for now, Download the Hello World application used in this tutorial here: HelloWorld
Regards,
sj
Below is a console log of all the fonts and font families from Dave Mitchell
Font Family: American Typewriter
Font: AmericanTypewriter
Font: AmericanTypewriter-BoldFont Family: AppleGothic
Font: AppleGothicFont Family: Arial
Font: ArialMT
Font: Arial-BoldMT
Font: Arial-BoldItalicMT
Font: Arial-ItalicMTFont Family: Arial Rounded MT Bold
Font: ArialRoundedMTBoldFont Family: Arial Unicode MS
Font: ArialUnicodeMSFont Family: Courier
Font: Courier
Font: Courier-BoldOblique
Font: Courier-Oblique
Font: Courier-BoldFont Family: Courier New
Font: CourierNewPS-BoldMT
Font: CourierNewPS-ItalicMT
Font: CourierNewPS-BoldItalicMT
Font: CourierNewPSMTFont Family: DB LCD Temp
Font: DBLCDTempBlackFont Family: Georgia
Font: Georgia-Bold
Font: Georgia
Font: Georgia-BoldItalic
Font: Georgia-ItalicFont Family: Helvetica
Font: Helvetica-Oblique
Font: Helvetica-BoldOblique
Font: Helvetica
Font: Helvetica-BoldFont Family: Helvetica Neue
Font: HelveticaNeue
Font: HelveticaNeue-BoldFont Family: Hiragino Kaku Gothic **** W3
Font: HiraKakuProN-W3Font Family: Hiragino Kaku Gothic **** W6
Font: HiraKakuProN-W6Font Family: Marker Felt
Font: MarkerFelt-ThinFont Family: STHeiti J
Font: STHeitiJ-Medium
Font: STHeitiJ-LightFont Family: STHeiti K
Font: STHeitiK-Medium
Font: STHeitiK-LightFont Family: STHeiti SC
Font: STHeitiSC-Medium
Font: STHeitiSC-LightFont Family: STHeiti TC
Font: STHeitiTC-Light
Font: STHeitiTC-MediumFont Family: Times New Roman
Font: TimesNewRomanPSMT
Font: TimesNewRomanPS-BoldMT
Font: TimesNewRomanPS-BoldItalicMT
Font: TimesNewRomanPS-ItalicMTFont Family: Trebuchet MS
Font: TrebuchetMS-Italic
Font: TrebuchetMS
Font: Trebuchet-BoldItalic
Font: TrebuchetMS-BoldFont Family: Verdana
Font: Verdana-Bold
Font: Verdana-BoldItalic
Font: Verdana
Font: Verdana-ItalicFont Family: Zapfino
Font: Zapfino
iDevKit Has A New Look
After getting too busy with other projects lately, iDevKit has fallen to the wayside. We’ve decided to take a new turn with the website and start an iPhone developer’s blog! We plan on releasing a large number of iPhone development specific tutorials for all of the developers out there. Stay tuned for coming updates this week, where we hope to issue our first tutorials!
Thanks,
iDevKit