Ios 在另一个模型对象内对模型对象数组进行排序
我有一个名为Ios 在另一个模型对象内对模型对象数组进行排序,ios,objective-c,sorting,cocoa-touch,nsarray,Ios,Objective C,Sorting,Cocoa Touch,Nsarray,我有一个名为MYView的自定义对象数组。它包含一个名为通知的自定义对象数组。在Notification中,我有一个名为color的属性,它包含一个介于1和6之间的值。我需要根据以下条件对MYView对象数组进行排序 MYView的类结构 @interface MYView : NSObject @property (nonatomic) NSInteger viewID; @property (nonatomic)
MYView
的自定义对象数组。它包含一个名为通知的自定义对象数组。在Notification
中,我有一个名为color
的属性,它包含一个介于1和6之间的值。我需要根据以下条件对MYView
对象数组进行排序
MYView的类结构
@interface MYView : NSObject
@property (nonatomic) NSInteger viewID;
@property (nonatomic) NSInteger userId;
@property (readonly, strong, nonatomic) NSString *viewName;
@property (readonly, nonatomic, strong) NSString *viewCreaterName;
@property (readonly, nonatomic, strong) NSArray *arrayOfNotifications; // This contains notification objects </i>
@接口MYView:NSObject
@属性(非原子)NSInteger viewID;
@属性(非原子)NSInteger用户ID;
@属性(只读、强、非原子)NSString*viewName;
@属性(只读、非原子、强)NSString*viewCreaterName;
@属性(只读、非原子、强)NSArray*arrayOfNotifications;//它包含通知对象
班级通知
@interface Notification : NSObject
@property (readonly, nonatomic) NSInteger sColorStatus; // This contains severity value. i.e 6,5..1.
@property (readonly, nonatomic) NSInteger iNotificationID;
@property (readonly, nonatomic) NSString *warningName;
@property (readonly, nonatomic) NSString *warningIcon;
@property (readonly, nonatomic) NSArray *rReplacementValuesArray;</i>
@接口通知:NSObject
@属性(只读,非原子)NSInteger sColorStatus;//它包含严重性值。i、 e 6,5..1。
@属性(只读,非原子)NSInteger iNotificationID;
@属性(只读,非原子)NSString*warningName;
@属性(只读,非原子)NSString*警告图标;
@属性(只读,非原子)NSArray*rReplacementValuesArray;
警告的严重性。
- 警告最严重的视图将列在顶部。
李>
- 其次,顺序基于严重警告的数量。如果多个视图具有严重警告,则具有最多严重警告的视图将位于列表顶部。
李>
通知数量
- 虽然严重性优先于卷,但第二个排序参数基于通知的数量。
李>
- 如果多个视图在相同的严重性级别上具有相同数量的通知,则列表按字母顺序排列。
李>
阿尔法阶
- 如果没有出现警告,列表将按字母顺序排列
我曾多次尝试使用排序描述符实现,但未能满足所有条件。向我们展示您迄今为止的尝试。您应该在sortedarrayingcomparator:
中使用自定义块比较器。