Showing posts from 2010

Great advanced iPhone tutorials
awesome source

Some CG Functions

Objective C Comment Tags

While writing a software one has to work across multiple files and its easy to forget those mental notes we make to revisit certain parts of the code. Objective C and Xcode provide some niftly tags to mark these areas in the code. The Tags are:

// TODO: add function call

// FIXME: remove view and add image

3) ???
// ???: How does this work?

4) !!!
// !!!: to be verified


Base64 encoding in objective c

this is what worked for me. May be a lot more later.
// encode64.m
// encode64vr1
// Created by Shubham Goel on 11/11/10.
// Copyright 2010 What an All rights reserved.

#import "encode64.h"

@implementation encode64

static char base64EncodingTable[64] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',

Website Design Time Saving Tools

Add background to table view

Add a view with the image to the window or the view controlling the table view. In my case it was a navigation view. UIView *backgroundView = [[UIView alloc] initWithFrame: window.frame];
backgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"TableViewBackground.png"]];
[window addSubview:backgroundView];
[backgroundView release];
Code from:

Changing the accessory view icon

Changing the stupid accessory icon is small exercise if you know precisely the right steps.

Create the icon and change the accessory view to the icon view
UIButton* pencil = [UIButton buttonWithType:UIButtonTypeCustom];
[pencil setImage:[UIImage imageNamed:@"icon-pencil.gif"] forState:UIControlStateNormal];
pencil.frame = CGRectMake(0, 0, 15, 15);
pencil.userInteractionEnabled = YES;
[pencil addTarget:self action:@selector(didTapEditButton:) forControlEvents:UIControlEventTouchDown];
cell.accessoryView = pencil;
Code from:
as a custom controller has been called it need to know the IndexPath. For that use: - (void)checkButtonTapped:(id)sender event:(id)event { NSSet *touches = [event allTouches]; UITouch *touch = [touches anyObject]; CGPoint currentTouchPosition = [touch locationInView:self.tableView]; NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition]; if (indexPath != nil) { [self tableView:…

Using custom delegates in Objective-C

On Stack Overflow there has been some interest in how to use the Delegate design pattern in Objective-C. Of course, the first step in any search should be to read Apple's documentation, but many people seem not to want to read the whole thing. Trust me, folks, it is worth it. But Apple's documentation on creating delegates doesn't use protocols, which are such an amazing and useful part of the Objective-C language.That being said, I'd like to give a short demonstration of how to create a class with a delegate. For the purposes of this tutorial, we'll call our class JSTutorial. The interface to JSTutorial starts out as the following:@interfaceJSTutorial:NSObject{ NSString*title; NSString*body; }

Change wallpaper programatically

Via: Undocumented APIs to set and get the iPhone wallpaper programmatically. I hope these are legalized soon. There would be no end to the kind of things that can be done with them+defaultDesktopImageSignature+(UIImage*)defaultDesktopImage;Available in2.0 –Return the user's lock screen image.+setDesktopImageData:Signature+(void)setDesktopImageData:(NSData*)jpegData;Available in2.0 –Replace the user's lock screen image by the given JPEG data.

What is ASIHTTPRequest?

ASIHTTPRequest is an easy to use wrapper around the CFNetwork API that makes some of the more tedious aspects of communicating with web servers easier. It is written in Objective-C and works in both Mac OS X and iPhone applications.
It is suitable performing basic HTTP requests and interacting with REST-based services (GET / POST / PUT / DELETE). The included ASIFormDataRequest subclass makes it easy to submit POST data and files using multipart/form-data.

MFMessageComposeViewController Sample Code (OS 4.0 only)

Start a new View-based Application Project called SMS2
and have to add the MessageUI framework to the project

Modify SMS2ViewController.h

// SMS2ViewController.h
// SMS2


@interface SMS2ViewController : UIViewController {
UILabel *message;

@property (nonatomic, retain) UILabel *message;



and in SMS2ViewController.m

// SMS2ViewController.m
// SMS2

#import "SMS2ViewController.h"

@implementation SMS2ViewController
@synthesize message;

// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
return self;

// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {


Shake Gesture

If you are planning to use the shake gesture to trigger an event add the following code to your UIViewController