文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Core Data Relationships(Chapter 30 of Cocoa Programming for Mac OS X)

Core Data Relationships(Chapter 30 of Cocoa Programming for Mac OS X)

时间:2011-04-06  来源:Ray Z

 1 #import "Department.h"
 2 #import "Employee.h"
 3 
 4 @implementation Department
 5 @dynamic deptName;
 6 @dynamic employees;
 7 @dynamic manager;
 8 
 9 /*
10 - (void)addEmployeesObject:(NSManagedObject *)value {    
11     NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
12     [self willChangeValueForKey:@"employees" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
13     [[self primitiveValueForKey:@"employees"] addObject:value];
14     [self didChangeValueForKey:@"employees" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
15     [changedObjects release];
16 }
17 
18 - (void)removeEmployeesObject:(NSManagedObject *)value {
19     NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
20     [self willChangeValueForKey:@"employees" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
21     [[self primitiveValueForKey:@"employees"] removeObject:value];
22     [self didChangeValueForKey:@"employees" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
23     [changedObjects release];
24 }
25 
26 
27 - (void)addEmployees:(NSSet *)value {    
28     [self willChangeValueForKey:@"employees" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
29     [[self primitiveValueForKey:@"employees"] unionSet:value];
30     [self didChangeValueForKey:@"employees" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
31 }
32 
33 - (void)removeEmployees:(NSSet *)value {
34     [self willChangeValueForKey:@"employees" withSetMutation:NSKeyValueMinusSetMutation usingObjects:value];
35     [[self primitiveValueForKey:@"employees"] minusSet:value];
36     [self didChangeValueForKey:@"employees" withSetMutation:NSKeyValueMinusSetMutation usingObjects:value];
37 }
38 */
39 - (void)addEmployeesObject:(Employee *)value
40 {
41     NSLog(@"Dept %@ adding employee %@", [self deptName], [value fullName]);
42     NSSet *s = [NSSet setWithObject:value];
43     [self willChangeValueForKey:@"employees" withSetMutation:NSKeyValueUnionSetMutation usingObjects:s];
44     [[self primitiveValueForKey:@"employees"] addObject:value];
45     [self didChangeValueForKey:@"employees" withSetMutation:NSKeyValueUnionSetMutation usingObjects:s];
46 }
47 
48 - (void)removeEmployeesObject:(Employee *)value
49 {
50     NSLog(@"Dept %@ removing employee %@", [self deptName], [value fullName]);
51     Employee *manager = [self manager];
52     if (manager == value) 
53     {
54         [self setManager:nil];
55     }
56     NSSet *s = [NSSet setWithObject:value];
57     [self willChangeValueForKey:@"employees" withSetMutation:NSKeyValueMinusSetMutation usingObjects:s];
58     [[self primitiveValueForKey:@"employees"] removeObject:value];
59     [self didChangeValueForKey:@"employees" withSetMutation:NSKeyValueMinusSetMutation usingObjects:s];
60 }
61 
62 @end
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载