iphone - 如何对其中包含类对象的 NSMutableArray 进行排序?

标签 iphone ios xcode ios-simulator

我有一个类 Events

@interface MeEvents : NSObject {
    NSString* name;**strong text**
    NSString* location;

}

@property(nonatomic,retain)NSString* name;strong text
@property(nonatomic,retain)NSString* location;

在我的 NSMutablArray 中我添加了事件对象

Events* meEvent;
[tempArray addObject:meEvent];

请告诉我如何按成员名称对这个数组进行排序。

最佳答案

NSSortDescriptor *sortDes = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:NO];
        [tempArray_ sortUsingDescriptors:[NSArray arrayWithObject:sortDes]];
        [sortDes release];

关于iphone - 如何对其中包含类对象的 NSMutableArray 进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9409291/

相关文章:

ios - 使用 xmpp 和 openfire 向用户发送好友请求

iphone - 为什么 Apple 不在 Interface Builder 中包含单选按钮?

ios - 如何在 iOS 上读取或解析 .mobi 文件

ios - 如何使用 Xcode 9.3 在 iOS 开发设备中检查 [NSUserDefaults standardUserDefaults]

iphone - 保护 Objective C 源代码中的敏感信息

iphone - 更新 iPhone 应用程序没有推送给我

ios - 观察 NSUserDefaults 中个别设置的变化

iphone - UILocalNotifications 播放自定义声音

ios - 嵌入容器中的 UITableView 不刷新

ios - 由于 dequeueWithReusableIdentifier,UICollectionView 加载速度非常慢,我可以在后台加载它吗?