我想以以下格式创建一个字符串:id[]=%@&stringdata[]=%@&id[]=%@&stringdata[]=%@&id[]=%@&stringdata[]=%@&
等。在for循环中我得到了id和stringdata,但是当我打印出testString时说(null),但是当我打印出Ident和Stringdata时(第一个两个 NSLogs) id 确实打印出来了,stringdata 也显示为 (null),因为此时字符串是空的,所以这很正常。
for(NSUInteger i = 0; i<self.childViewControllers.count; i++) {
NSLog(@"Ident: %@",((myViewController*)[self.childViewControllers objectAtIndex:i]).ident);
NSLog(@"Stringdata: %@",((myViewController*)[self.childViewControllers objectAtIndex:i]).getQAnswer);
testString = [testString stringByAppendingString:([NSString stringWithFormat: @"id[]=%@&stringdata[]=%@&",((myViewController*)[self.childViewControllers objectAtIndex:i]).ident ,((myViewController*)[self.childViewControllers objectAtIndex:i]).getQAnswer])];
NSLog(@"PostString : %@",testString);
}