Randomize Everything

Icon

And create the perfect world

Completely Uninstall XCode And Developer Tools

If you’re running into troubles with your XCode installation or Developer Tools and like to reinstall the whole thing, you should enter the following command in your Terminal application to uninstall the whole developer package:

sudo /Developer/Library/uninstall-devtools –mode=all

Encoding HTML entities In Objective C

When sending data to a backend server you sometimes need to encode special characters to HTML entities. To encode those characters in a string use the method: stringByAddingPercentEscapesUsingEncoding. Consider the following example to make it a bit more clear:

NSString *urlString = [NSString stringWithFormat:@"%@%@", @"http://www.this-is-a-url.com/accept.php?identifier=", uniqueDeviceIdentifier];
urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"Upload to server: %@", urlString);

Short note: the first line of the example shows you how to concatenate two strings.

Displaying Custom Fonts In Objective-C (iPhone SDK)

Coming from the Flash Platform I’m used to do a lot of font embedding in my projects. A few week ago I looked into this topic when programming an iPad application which needed a complete design makeover with custom fonts to spice it up a bit.

So how do you go about including custom fonts in an iPhone/iPad project? Well, it’s not that hard if you’re having a little bit of objective-c experience. You should download the FontLabel library, add it to your project and start creating FontLabel instances in code. I sense you feel the need for an example, so here it is:

FontLabel *questionLabel = [[FontLabel alloc] initWithFrame:CGRectMake(60, 115, 900, 130) fontName:@"DINPro-Medium" pointSize:30.0f];
questionLabel.textColor = [UIColor whiteColor];
questionLabel.textAlignment = UITextAlignmentCenter;
questionLabel.lineBreakMode = UILineBreakModeTailTruncation;
questionLabel.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
questionLabel.numberOfLines = 0;
[self.view addSubview:questionLabel];
[questionLabel release];

“DINPro-Medium” is a TrueType font included in my resources bundle. Please do mind that FontLabel currently only accepts TrueType fonts, so you might want to convert some of those non-ttf fonts to ttf. A good online font converter can be found here: http://onlinefontconverter.com/

Hit Testing A Non-Transparent Area In Objective C

Coding hit tests has always been a hassle when transparent .png files come into the game. That’s why Jeff Lamarche has extended the standard UIButton and added the hit testing of transparent .png buttons. This new class will only return a valid hit when you are touching a non-transparent part of the .png image.

More information and the downloadable source can be found here.

Some example code to get you going:

-(void)viewDidLoad
{
	UIImage *image = [UIImage imageNamed:@"image-in-resources.png"];
	IrregularShapedButton *irrButton = [[IrregularShapedButton buttonWithType:UIButtonTypeCustom] retain];
	[irrButton setImage:image forState:UIControlStateNormal];
	irrButton.frame = CGRectMake(0, 0, image.size.width, image.size.height);
 
	[self.view addSubview:irrButton];
	[super viewDidLoad];
}
 
- (IBAction)buttonClick:(id)sender
{
    NSLog(@"Clicked:%@", sender);
}

Automator SVN-delete and deploy workflow

Almost all of my projects are placed under svn version control, a great way to manage different project versions. But when the time is there to put everything online I have to clear all auto-created .svn files and folders. This doesn’t only save space but it’s also a more secure way to deploy files.
A few weeks back I created an automator workflow to do all this stuff automagically and today is the time I share this with you developers out there.

What it actually does:
- It prompts you with the folder you’d like to export
- It takes a copy of the folder and pastes it onto the desktop
- It removes all the .svn files and folders
- It shows the newly exported folder in a finder window
- Your original files won’t be harmed

You can download the compiled automator script here.
If you’d like to change the workflow to fit your own needs (i.e.: you can open your favorite FTP client after the process) then download the automator workflow here.

Just a little sidenote: you can also export your project from your subversion client like Versions or Cornerstone.

Quicktip #6: Fixing the cut off character on embedded-font-textfields

As we all know, Flash has these crazy bugs nobody ever understands. One of those is the fact that the last character of a dynamic textfield (which has been set to “AutoSize”) gets cut off when you’re using an embedded font. Up till now I still don’t understand what kind of situation leads to this exceptional behavior. The only thing I can say is that Flash Player fails to determine the correct text length which screws up the textfield width to be shorter than it has to be.

Example:

Blurred/Cut Off Characters

Blurred/Cut Off Characters


Read the rest of this entry »

Quicktip #5: int is faster than uint

The past few weeks I’ve been programming a scheduling component in Flash which has to be extremely performant. Every small adaption in my code that could help with limiting the processing needs is a good adaption. Today I stumbled upon a post of Grant Skinner in which he explains that using a uint is slower than a normal int. The uint’s can get five times slower than using a normal int.

Read the rest of this entry »

Adobe Certified Flash CS3 Developer

In times of crisis there is little few work than other busy-o-noo-we-have-to-reach-our-deadline-developer-days.

So, there are a few useful things we can do: invest our time into new technologies or play with things (with the technology we daily use) we didn’t play with before. Mostly because we didn’t have enough time back then. The second most useful thing we can do is getting a certificate for the technologies we use every day.

Read the rest of this entry »

Quicktip #1: Casting to Number()

Did you know that casting a String to a Number using the ‘as’ operator returns 0 instead of the correct number? Use the Number() constructor to cast it correctly. The same applies for ‘int’ and ‘uint’.

Read the rest of this entry »

Code snippet: Trimming texts in AS2

From time to time some of us still have to code in oldskool ActionScript 2. A few days ago a colleague asked me for a function for trimming ‘new line’ (\n), ‘carriage return’ (\r) characters, spaces, …
So I ended up searching my archives for a code snippet to archive this functionality and look what I found:

Read the rest of this entry »