VSStringComposing 是一组简单的 Objective-C 分类,允许您轻松地组合 NSString 对象。
VSComposing
文件夹拖到您的项目。<VSStringComposing/NSString+VSComposing.h>
或 <VSStringComposing/NSArray+VSComposing.h>
头文件NSString *firstName = @"Volodymyr";
NSString *lastName = @"Shevchenko";
NSNumber *yearOfBirth = @(1989);
NSArray *arrayToCompose = @[@"My name is ", firstName, @" ", lastName, @". I was born in ", yearOfBirth, @"."];
NSString *composedString = [NSString composeFromArray:arrayToCompose];
NSLog(@"%@", composedString);
// result : My name is Volodymyr Shevchenko. I was born in 1989.
NSString *otherComposedString = arrayToCompose.composedContent;
NSLog(@"%@", otherComposedString);
// result : My name is Volodymyr Shevchenko. I was born in 1989.