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 snippet here’s an example how to use it.
-
#import "Assert.h"
-
-(void)doSomething{
-
[Assert that:(<your_assertion>)];
-
}
My name is Piter Jankovich. oOnly want to tell, that your blog is really cool
And want to ask you: is this blog your hobby?
P.S. Sorry for my bad english