有两个文件。让我们打电话给fileOne
他们fileTwo
每个都有几个具有相同名称的 NSMutableDictionary 属性。列举几个:
@property (retain, nonatomic) NSMutableDictionary * lunchStartTimeObject;
@property (retain, nonatomic) NSMutableDictionary * lunchLocationNameObject;
@property (retain, nonatomic) NSMutableDictionary * lunchLocationAddressObject;
@property (retain, nonatomic) NSMutableDictionary * activity1NameObject;
@property (retain, nonatomic) NSMutableDictionary * activity1StartTimeObject;
@property (retain, nonatomic) NSMutableDictionary * activity1LocationNameObject;
@property (retain, nonatomic) NSMutableDictionary * activity1CommentsFieldObject;
@property (retain, nonatomic) NSMutableDictionary * activity1LocationAddressObject;
@property (retain, nonatomic) NSMutableDictionary * activity2NameObject;
@property (retain, nonatomic) NSMutableDictionary * activity2StartTimeObject;
@property (retain, nonatomic) NSMutableDictionary * activity2LocationNameObject;
@property (retain, nonatomic) NSMutableDictionary * activity2CommentsFieldObject;
@property (retain, nonatomic) NSMutableDictionary * activity2LocationAddressObject;
我想通过调用下面的方法(或类似的方法)来比较两个文件中同名的字典:
-(NSMutableDictionary *)cellColorForChanges:(NSMutableDictionary *)newdictionary :(NSMutableDictionary *)oldDictionary;
{
if(![newdictionary isEqualToDictionary:oldDictionary])
{
[newdictionary setValue:@"UIColor yellowColor" forKey:@"cellColor"];
}
return newdictionary;
}
我试图避免手动为每个 NSMutableDictionary 编写代码。有没有办法避免以下情况:
if(![fileOne.lunchStartTimeObject isEqualToDictionary:fileTwo.lunchStartTimeObject])
{
fileOne.lunchStartTimeObject setValue:@"UIColor yellowColor" forKey:@"cellColor"];
}
我无法找出完成上述任务的最有效方法。是否有可能将每个字典发送到一个方法并取回字典(如果它不相等,则用另一个键更新)?或者我试图避免的是不可避免的?