gpt4 book ai didi

ios - 代码优化(2行代码合并为1行)

转载 作者:行者123 更新时间:2023-11-28 18:22:26 24 4
gpt4 key购买 nike

我尝试了一些组合,但似乎无法正确组合。我希望将第 2 行和第 3 行合并为一行代码。

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name == 'SSM M51 Copperhead'"];
NSArray *searchResults1 = [self.weaponsArray filteredArrayUsingPredicate:predicate];
weapons = [searchResults1 objectAtIndex:0];
if(weapons.range > SSMrange)
SSMrange = weapons.range;

('武器'是一个类)。

最佳答案

weapons = [self.weaponsArray filteredArrayUsingPredicate:predicate][0];

但这并不会真正使您的代码更快。

关于ios - 代码优化(2行代码合并为1行),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17750370/

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