【发布时间】:2015-09-23 15:58:44
【问题描述】:
我正在尝试用现有的 URL IP 地址替换我的自定义 IP 地址。如何用现有 IP 替换我的 IP 地址。请在下面找到代码sn-p
- (IBAction)btnSubmit:(UIButton *)sender {
NSString *ipAdd = [_txtIPAddress text];
NSLog(@"My entered IP Address is %@", ipAdd);
NSLog(@"Current pointing server value is %@", [ConnManager activeEndpoint]);
NSLog([App appDelegate].isConfigured ? @"Yes" : @"No");
NSArray *listItems = [[ConnManager activeEndpoint] componentsSeparatedByString:@"/"];
ConnManager *conn = [[ConnManager alloc] init];
NSMutableString *configuredUrl = nil;
[configuredUrl setString:@""];
for ( NSInteger i =0; i < listItems.count; i++) {
if(i != 2) {
NSMutableString * arrayElement = [(NSMutableString*)listItems objectAtIndex:i];
NSMutableString *str = [NSMutableString stringWithFormat: @"%@/", arrayElement];
[configuredUrl appendString:str];
} else {
NSMutableString *configstr = [NSMutableString stringWithFormat: @"%@", ipAdd];
NSLog(@"ConfigString %@", configstr);
//How to replace the my ip address with the array index[2]
configuredUrl = [configuredUrl stringByAppendingFormat:configstr];
NSLog(@"Configured Url after apppending %@", configuredUrl);
提前致谢
【问题讨论】:
标签: arrays string replace substring