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

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM