Apologies if you get any glitches while browsing the blog. I am currently developing a new theme and am running some real life testing. This should only happen for a few days max. I you have any major issues please comment and let me know and I will endeavor to resolve them asap. Thanks for [...]
Fitness test, the iPhone application is now on sale. Thanks :)
To use the accelerometer in an iPhone application you need to add the <UIAccelerometerDelegate> into the .h file of your application:
@interface ApplicationViewController : UIViewController <UIAccelerometerDelegate>{
Then in your .m file you must setup the accelerometer:
- (void)viewDidLoad {
UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = self;
accel.updateInterval = 1/30;
}
Update interval is in seconds so 1/30 is a 30th of a [...]
First we need an array to hold the objects (in this case bullets)
NSMutableArray *myBullets = [[NSMutableArray alloc] init];
Create and then add the objects
for (int i=0; i<5; i++){
//create
Bullet *newBullet = [[Bullet alloc] init];
//add to the array
[myBullets addObject: newBullet];
//release the object here as its retained in the array
[newBullet release];
}
//myBullets now has [...]
Airluminate v 2.0 has been submitted to iTunes for approval, fingers crossed it will be on sale/for update asap.
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
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
[application setStatusBarStyle:UIStatusBarStyleBlackOpaque];
To round a number use the following code:
CGFloat variable = …
CGFloat result = round(variable * 1000.0) / 1000.0;
or
CGFloat variable = round(variable * 1000.0) / 1000.0;
Use 1000 for 3decimal places, 100 for 2 etc!
This is a simple timer, you may need to declare some variables in the .h file.
-(void)onViewDidLoad {
//set on start up
NSDate *startTime = [NSDate date];
}
-(void)someOtherFunction {
//amount to dely by (seconds)
NSInteger *delayAmount = 1;
//work out the current delay time
NSTimeInterval elapsedTime = [startTime timeIntervalSinceNow];
//if the delay is bigger than the specified amount then…
if (elapsedTime >= delayAmount) [...]
To convert a string of a number (”568″) to a integer (568):
//aString = "568"
NSInteger *aNSintegerNumber = [aString integerValue];
//aNumber =568
or
//aString = "568"
int *aIntNumber = [aString intValue];
//aIntNumber = 568