author | Michael Krelin <hacker@klever.net> | 2012-12-08 21:19:17 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2012-12-11 21:59:29 (UTC) |
commit | 8808689fe340bec6e90ab13dd502292b0579cf1f (patch) (unidiff) | |
tree | 45b7c863151341f687b74e40bffcbd7ab5468783 /pumpkin/IPFormatter.m | |
parent | 6e7e413ca364d79673e523c09767c18e7cff1bec (diff) | |
download | pumpkin-osx/0.0.zip pumpkin-osx/0.0.tar.gz pumpkin-osx/0.0.tar.bz2 |
initial osx portosx/0.0
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | pumpkin/IPFormatter.m | 21 |
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 | ||