iOS-字符串的连接

越努力.越幸福.----willingseal.



(一)连接两个字符串


  NSString  *type=[ self . type objectAtIndex:typeRow];
    NSString *subtype=[self.subtypeobjectAtIndex:subtypeRow];
    
   
(1)  NSString *typesub = [NSString stringWithFormat:@"%@>%@",type,subtype];
    
(2)  NSString *typesub = [type stringByAppendingString:subtype];
    
(3) NSString *typesub = [type stringByAppendingFormat:@"%@>%@",type,subtype];
    

      NSLog ( @"%@" ,typesub);

打印:(1) 交通 > 出租车费
(2) 交通出租车费
(3) 交通交通 > 出租车费


(二)连接三个字符串

  NSString  *a= @"abc" ;
    

    NSString  *typesub = [type  stringByAppendingFormat : @"%@>%@>%@" ,type,subtype,a];

打印: 交通交通 > 出租车费 >abc

 

 

 

posted @ 2013-06-05 21:45  jlins  阅读(6888)  评论(0编辑  收藏  举报