Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 11 years ago.
最简单的方法是:
NSArray *reversed = [[yourArray reverseObjectEnumerator] allObjects];
The easiest way to do it is:
您需要类似的内容:
NSMutableArray* reversedMessages = [NSMutableArray arrayWithCapacity:[messages count]]; NSEnumerator* reverseEnumerator = [messages reverseObjectEnumerator]; for (id object in reverseEnumerator) { [reversedMessages addObject:Object]; }
然后,您可以将ReversedMessages分配给消息,也可以对此进行其他操作。
ReversedMessages
消息
You need something like:
You could then assign reversedMessages to messages or do whatever else you want with it.
reversedMessages
messages
你可以颠倒 NSArray 的顺序,如下所示:
- (NSArray *)reverseArray:(NSArray*)array { NSMutableArray *mArray = [NSMutableArray arrayWithCapacity:[array count]]; NSEnumerator *enumerator = [array reverseObjectEnumerator]; for (id element in enumerator) { [mArray addObject:element]; } return mArray; }
You can reverse the order of an NSArray like this:
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(3)
最简单的方法是:
The easiest way to do it is:
您需要类似的内容:
然后,您可以将
ReversedMessages
分配给消息
,也可以对此进行其他操作。You need something like:
You could then assign
reversedMessages
tomessages
or do whatever else you want with it.你可以颠倒 NSArray 的顺序,如下所示:
You can reverse the order of an NSArray like this: