The only thing I can think of is to use something like "http://www.dyndns.org/cgi-bin/check_ip.cgi" others may have a be
2012-03-13 13:50
1131 查看
NSUInteger an_Integer; NSArray* ipItemsArray; NSString*externalIP; NSURL *iPURL =[NSURL URLWithString:@"http://www.dyndns.org/cgi-bin/check_ip.cgi"]; if(iPURL){ NSError*error = nil; NSString*theIpHtml =[NSString stringWithContentsOfURL:iPURL encoding:NSUTF8StringEncoding error:&error]; if(!error){ NSScanner*theScanner; NSString*text = nil; theScanner =[NSScanner scannerWithString:theIpHtml]; while([theScanner isAtEnd]== NO){ // find start of tag [theScanner scanUpToString:@"<" intoString:NULL]; // find end of tag [theScanner scanUpToString:@">" intoString:&text]; // replace the found tag with a space //(you can filter multi-spaces out later if you wish) theIpHtml =[theIpHtml stringByReplacingOccurrencesOfString: [NSString stringWithFormat:@"%@>", text] withString:@" "]; ipItemsArray =[theIpHtml componentsSeparatedByString:@" "]; an_Integer=[ipItemsArray indexOfObject:@"Address:"]; externalIP =[ipItemsArray objectAtIndex: ++an_Integer]; } NSLog(@"%@",externalIP); }else{ NSLog(@"Oops... g %d, %@", [error code], [error localizedDescription]); } } [pool drain]; return0;
相关文章推荐
- Inteface Buidler can't determine the type of "xx.xib" this may be due to a missing SDK.
- How can I set the background of UITableView (the tableview style is "Grouped") to use an image?
- The best way to be "right once" is to have the ability to envision what things are going to look like three weeks, three months
- restoration of CBCentralManager is only allowed for applications that have specified the "bluetooth-
- 'Push segues can only be used when the source controller is managed by an instance of UINavigationC
- nginx: [warn] the "log_format" directive may be used only on "http" level 解决方法
- Use crash to show the code line of a backtrace entry like "ocfs2_truncate_file+0x127/0x6c0"
- Use MFC in a Static Library,This may be due to a corruption of the heap....
- Can not find the tag library descriptor for "http://www.springframework.org/tags/form" 解决方法
- 【406错误】 The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.
- 托福写作5-what is the most important characteristic that a person can have to be successful in life
- SharePoint 2013 搜索报错"Unable to retrieve topology component health. This may be because the admin component is not up and running"
- It is said that wars in the 21st century will be fought over water. Do you agree? What do you think can be done now to alleviate
- Can not find the tag library descriptor for "http://www.springframework.org/security/tags"
- This function has none of Deterministic,no sql,or reads sql data in its declaration and binary logging is enabled(you *might* want to use the less safe log_bin_trust_function_creators variable
- Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive
- vs2005下出现“Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive”的解决方法
- "Your computer could not be joined to the domain. You have exceeded the maximum number of computer accounts you are allowed to create in this domain. Contact your system administrator to have this limit reset or increased."
- Only one instance of a ScriptManager can be added to the page.
- http://url is already routed to the Default zone of another application. Remove that mapping or use a different URL