Follow Me on Twitter
<div style="background-color: none transparent;"><a href="http://www.rsspump.com/?web_widget/rss_widget/twitter_widget" title="web widget">Twitter Widget</a></div>

iPhone SDK Random UIColor

Sometimes when testing things out you just need to give something a random background color. Here is a snippet for generating a random UIColor.

Found At
// UIColor+Random.h
@interface UIColor (Random)

+ (UIColor *) randomColor;

@end
// UIColor+Random.m
#import "UIColor+Random.h"

@implementation UIColor (Random)

+ (UIColor *) randomColor
{
	CGFloat red =  (CGFloat)random()/(CGFloat)RAND_MAX;
	CGFloat blue = (CGFloat)random()/(CGFloat)RAND_MAX;
	CGFloat green = (CGFloat)random()/(CGFloat)RAND_MAX;
	return [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
}

@end

Wednesday ( 6 / 9 / 2010 )

Artifice Open Source!

I have decided to make my iPhone game Artifice open source. Due to family obligations I can no longer support this game. This work is licensed under a Creative Commons Attribution 3.0 Unported License. You may use this code in any way you want. All I ask is a credit for the work I did with a link to kwigbo.com.

Features

  • Cocos2d / UIKit mixture
  • OpenFeint integration
  • Push Notifications via Urban Airship
  • Online turn based multiplayer
  • App Engine application backend
Get the source code here!
Wednesday ( 6 / 9 / 2010 ) — 1 note

iPhone SDK Memory Management

Here is a great article on memory management in Objective-C

Memory Management

Tuesday ( 6 / 8 / 2010 )

iPhone SDK Get Path For File

Here are two snippets that show how to get the path for a file in the documents directory or the main bundle.

// Main Bundle
NSString *pathInMainBundle = [[NSBundle mainBundle] pathForResource:@"example" ofType:@".png"];

// Documents Directory
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsDir = [documentPaths objectAtIndex:0];
NSString *pathInDocuments = [docsDir stringByAppendingPathComponent:@"example.png"];

Tuesday ( 6 / 8 / 2010 )

Check If A File Exists

This simple snippet use the NSFileManager to check if a file exists.

NSFileManager *fileManager = [[NSFileManager alloc] init];
BOOL exists = [fileManager fileExistsAtPath:@"Path To File"];
[fileManager release];
Tuesday ( 6 / 8 / 2010 )