summaryrefslogtreecommitdiffabout
path: root/pumpkin/IPFormatter.m
Unidiff
Diffstat (limited to 'pumpkin/IPFormatter.m') (more/less context) (ignore whitespace changes)
-rw-r--r--pumpkin/IPFormatter.m21
1 files changed, 21 insertions, 0 deletions
diff --git a/pumpkin/IPFormatter.m b/pumpkin/IPFormatter.m
new file mode 100644
index 0000000..78a51b4
--- a/dev/null
+++ b/pumpkin/IPFormatter.m
@@ -0,0 +1,21 @@
1
2#import "IPFormatter.h"
3#include <arpa/inet.h>
4
5@implementation IPFormatter
6
7-(NSString *)stringForObjectValue:(id)obj {
8 if(![obj isKindOfClass:[NSString class]]) return nil;
9 return obj;
10}
11
12-(BOOL)getObjectValue:(id*)anObject forString:(NSString*)string errorDescription:(NSString**)error {
13 if(inet_addr(string.UTF8String)==INADDR_NONE) {
14 if(error) *error=@"Doesn't look like an IP address to me";
15 return NO;
16 }
17 *anObject = [NSString stringWithString:string];
18 return YES;
19}
20
21@end