gpt4 book ai didi

ios - 在 Cocoa 中组合多个字符串

转载 作者:行者123 更新时间:2023-11-29 03:19:23 26 4
gpt4 key购买 nike

我希望能够将每个索引组合起来,这样我就可以得到@"生物老师A BK 1",但是到目前为止我一直没有成功。到目前为止,这是我所拥有的,但我不知道从这里去哪里。

@interface ListTableViewController () <UISearchDisplayDelegate>

@property (strong, nonatomic) NSArray *className;
@property (strong, nonatomic) NSArray *teacherName;
@property (strong, nonatomic) NSArray *blockNumber;

@end

@implementation ListTableViewController

- (void)viewDidLoad {

[super viewDidLoad];
self.className = [NSArray arrayWithObjects:
@"Biology",
@"English III",
@"Chemistry",
@"Algebra II",
@"Morality", nil];

self.teacherName = [NSArray arrayWithObjects:
@"Teacher A",
@"Teacher B",
@"Teacher C",
@"Teacher D",
@"Teacher E", nil];

self.blockNumber = [NSArray arrayWithObjects:
@"BK 1",
@"BK 3",
@"BK 6",
@"BK 2",
@"BK 1", nil];
}

最佳答案

它会起作用:

   for (int i = 0 ; i< self.className.count; i++)
{
NSString *temStr = [NSString stringWithFormat:@"%@ %@ %@",[self.className objectAtIndex:i] ,[self.teacherName objectAtIndex:i],[self.blockNumber objectAtIndex:i] ];
NSLog("%@", tempStr);
}

关于ios - 在 Cocoa 中组合多个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21300193/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com