Skip to content

Category Archives: IPhone

The iPhone is an Internet-connected, multimedia smartphone designed and marketed by Apple Inc. Because its minimal hardware interface lacks a physical keyboard, the multi-touch screen renders a virtual keyboard when necessary. The iPhone functions as a camera phone (also including text messaging and visual voicemail), a portable media player (equivalent to a video iPod), and an Internet client (with email, web browsing, and Wi-Fi connectivity). – Wikipedia.

Accelerometer setup and usage

To use the accelerometer in an iPhone application you need to add the <UIAccelerometerDelegate> into the .h file of your application: [code lang="c_mac"]@interface ApplicationViewController : UIViewController {[/code] Then in your .m file you must setup the accelerometer: [code lang="c_mac"] - (void)viewDidLoad { UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer]; accel.delegate = self; accel.updateInterval = 1/30; } [/code] [...]

Airluminate v2.0 update submitted

Airluminate v 2.0 has been submitted to iTunes for approval, fingers crossed it will be on sale/for update asap.

Airluminate on sale!

My first application, Airluminate is now on sale on iTunes. It is available for download for the iPhone and iPod Touch and is on sale for $0.99. Airluminate is primarily an light that changes with movement and rotation and is designed as a fun tool for long exposure photographs. Airliminate site: Airluminate iTunes store: Airluminate

Changing the iPhone status bar

Just use this code to change the type of status bar shown. Stick it in the applicationDidFinishLaunching method which is usually in your MyAppDelegate.m [code lang="c_mac"] [application setStatusBarStyle:UIStatusBarStyleBlackOpaque]; [/code]

Round a number

To round a number use the following code: [code lang="c_mac"] CGFloat variable = ... CGFloat result = round(variable * 1000.0) / 1000.0; [/code] or [code lang="c_mac"] CGFloat variable = round(variable * 1000.0) / 1000.0; [/code] Use 1000 for 3decimal places, 100 for 2 etc!

Objective C Timer

This is a simple timer, you may need to declare some variables in the .h file. [code lang="c_mac"] -(void)onViewDidLoad { //set on start up NSDate *startTime = [NSDate date]; } [/code] [code lang="c_mac"] -(void)someOtherFunction { //amount to dely by (seconds) NSInteger *delayAmount = 1; //work out the current delay time NSTimeInterval elapsedTime = [startTime timeIntervalSinceNow]; [...]

String to Number (integer)

To convert a string of a number (“568″) to a integer (568): [code lang="c_mac"] //aString = "568" NSInteger *aNSintegerNumber = [aString integerValue]; //aNumber =568 [/code] or [code lang="c_mac"] //aString = "568" int *aIntNumber = [aString intValue]; //aIntNumber = 568 [/code]