我有5个字符串我想要他们必须存储在singe NSString所有的值与|分开标志
NSString *first=@"Ali"; NSString *second=@"Imran"; NSString *third=@"AliImran"; NSString *fourth=@"ImranAli"; NSString *fifth=@"Ali Imran Jamshed";
我想要所有这些在单个NSString存储和所有的值分隔给定的符号.
解决方法
NSArray *myStrings = [[NSArray alloc] initWithObjects:first,second,third,fourth,fifth,nil]; NSString *joinedString = [myStrings componentsJoinedByString:@"|"]; // release myStrings if not using ARC.