[Valid RSS]

Assert statement in Objective C

Share

Hi,
if you like to use assertions in your source code, but you miss this feature in ObjectiveC, give a look to this small class.
Assert.h

#import <Foundation/Foundation.h>

@interface Assert : NSObject {

}

+(void)that:(BOOL)expr;

@end

Assert.m

#import "Assert.h"

@implementation Assert

+(void)that:(BOOL)expr{

 if (!expr) {

  [NSException raise:@"Failed assertion." format:@"Failed assertion", nil];

 }

}

@end

As you can see, there’s only one static method that you can use wherever you want.
In this [...]

Ruby on CentOS

Install a recent Ruby version in CentOS via Yum is almost impossible, since the packages are a little outdated. Maybe it is worth to give Enterprise Ruby a [...]

Database testing with Mono and NUnit

A class to set the database in a well know status before running an integration [...]

Obtain the root logger programmatically in log4net

Share

If you use log4net, you could have the need to configure the loggers programamtically. The problem arise when you want access to the root logger, since the documentation does not explain well how to obtain it.
So, here’s a snippet that show how to do it. Don’t forget to imort the log4net namespaces.

using log4net;

using log4net.Core;

using log4net.Appender;

using [...]

Good environment variable values during iPhone development

Share

Directly from GHUnit, a small note about which environment variables to set while developing for the iPhone.

Environment Variable: Default: Set to:
NSDebugEnabled [...]

Rails ans SQLite3 on Ubuntu

Share

To configure a Rails application in order to use SQLite3 please follow the following steps:

sudo apt-get install sqlite3 swig libsqlite3-ruby libsqlite3-dev
sudo gem install sqlite3-ruby

Then create a Rails application as usual and update the environment.rb file in the following way

Rails::Initializer.run do |config|

config.gem ’sqlite3-ruby’, :lib => “sqlite3″

end

Get rid of folder that should not be versioned

Share

If you work with subversion, for sure you had the problem to tell to subversion to ignore a folder inside your working copy. This happens for example if your IDE builds the sources in a folder inside your working copy. From the very first commit you’ll start noticing that subversion wants to add that “build” [...]

iPhone screen dimensions

Share

This picture can be useful to those of you that develop graphics targeted to the iPhone platform. Here you see the dimensions in pixel of an iPhone windows in some of the most common configurations. Click on the image to enlarge it.

Chosing the number of decimal digits when printing a number with iPhone

Share

This is a small snippet, useful whenever you want to convert a floating point number in a string with a fixed number of decimal digits.

NSNumberFormatter *format = [NSNumberFormatter new];
[format setMaximumFractionDigits:1];
NSNumber *aNumber = [[NSNumber alloc ] initWithDouble:54.4235264];
NSString label = [[NSString alloc] initWithFormat:@”The number is %@”, [format stringForObjectValue:aNumber]];
[distance release];
[format release];

Obviously the NSNumberFormatter [...]

iPhone: how to select a UITabBarItem programmatically

Share

I’m working to an iPhone application with a TabBar on the footer area. Among the others there are a “Home” button and an “Account” button. The first allows the user to see a view that gives an overview of the application. The latter shows the view that the user uses to manage his/her account.

If the [...]