nsorderedset

Why doesn't NSOrderedSet inherit from NSSet?

Deadly 提交于 2019-12-03 02:12:41
问题 Surely an ordered set is a more-specific case of a set, so why does NSOrderedSet inherit from NSObject rather than NSSet ? 回答1: I went through the interface of NSSet and you're right, ordered sets appear to satisfy the Liskov substitution principle and could therefor inherit from NSSet . There is one little method that breaks this: mutableCopy . The return value of mutableCopy must be an NSMutableSet , but NSMutableOrderedSet should inherit from NSOrderedSet . You can't have both. Let me

How to add element to NSOrderedSet for Core Data?

折月煮酒 提交于 2019-12-02 19:42:44
I did some studies on this post . But none of its solution work for me. Let me explain what I did: It's actually very similar with the mentioned post. Category.h @class Category, Item; @interface Category : NSManagedObject @property (nonatomic, retain) NSString * name; @property (nonatomic, retain) NSOrderedSet *items; @property (nonatomic, retain) Category *parentcategory; @property (nonatomic, retain) NSSet *subcategories; @end @interface Category (CoreDataGeneratedAccessors) - (void)insertObject:(Item *)value inItemsAtIndex:(NSUInteger)idx; - (void)removeObjectFromItemsAtIndex:(NSUInteger

Why doesn't NSOrderedSet inherit from NSSet?

走远了吗. 提交于 2019-12-02 15:44:05
Surely an ordered set is a more-specific case of a set, so why does NSOrderedSet inherit from NSObject rather than NSSet ? I went through the interface of NSSet and you're right, ordered sets appear to satisfy the Liskov substitution principle and could therefor inherit from NSSet . There is one little method that breaks this: mutableCopy . The return value of mutableCopy must be an NSMutableSet , but NSMutableOrderedSet should inherit from NSOrderedSet . You can't have both. Let me explain with some code. First, let's look at the correct behaviour of NSSet and NSMutableSet : NSSet* immutable

Core Data: Predicate for first element in orderd relationship

六月ゝ 毕业季﹏ 提交于 2019-11-28 10:07:29
问题 I have this to-many relationship which contains at least one element: Appointment <<------>> Invitee appointment.invitees is an ordered relationship resulting in an NSOrderedSet . In a table view controlled by a fetched results controller, I have the appointments listed, along with the first element of the invitees set. Now I want to search this list by invitees' names, using an NSPredicate . But how can refer to the first element of the ordered list in the predicate? I tried: fetchRequest

Core Data ordering with a UITableView and NSOrderedSet

喜夏-厌秋 提交于 2019-11-27 14:59:53
问题 What are the steps that I need to perform to implement user-defined ordering in a UITableViewController with Core Data as the backing store? Do I still need to respond to -tableView:moveRowAtIndexPath:fromIndexPath:toIndexPath: or is the model re-ordering handled automatically by the table view? Can I just check the "Ordered" checkbox in the Core Data model file and expect it to transmit the changes from the table view to the store, or do I have to do more? Do I have to change the way my