#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
//字符串拼接
NSString *[email protected]"pear",*[email protected]"apple";
//字符串格式化输出
NSString *newstr=[[NSString alloc]initWithFormat:@"拼接后%@ %@",str1,str2];
NSLog(@"%@",newstr);
NSString *newstr1=[str1 stringByAppendingString:str2];
NSLog(@"%@",newstr1);
//字符串格式化拼接
NSString *newstr2=[str1 stringByAppendingFormat:@"-%@",str2];
NSLog(@"%@",newstr2);
}
return 0;
}
时间: 2024-10-12 01:50:28