I want to define a min and max methods in a Utils class.
@interface Utils
int min(int a, int b);
int max(int a, int b);
@end
But I don\'t
In a template file named "XXIntegerMath.h" drop this...
#import
static inline NSInteger imax(NSInteger a, NSInteger b) {
return a > b ? a : b;
}
static inline NSInteger imin(NSInteger a, NSInteger b) {
return a < b ? a : b;
}
Then in your objective-c class ...
#import "XXIntegerMath.h"
NSInteger minValue = imin(someValue, someOtherValue);
It doesn't suffer from the problems described by Regexident.