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 [...]
Share
Directly from GHUnit, a small note about which environment variables to set while developing for the iPhone.
Environment Variable: Default: Set to:
NSDebugEnabled [...]
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.
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 [...]
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 [...]
How to implement a read-only computed property in [...]