Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的意思是简单地获取新数组,例如在 python 中:
lst[:-1]
有没有办法在objc中做到这一点?
您可以使用-subArrayWithRange:。
[theOriginalArray subarrayWithRange:NSMakeRange(0, [theOriginalArray count]-1)]
这相当于 Python 表达式lst[0:lst-1],它是您的lst[:-1].
lst[0:lst-1]