-
Notifications
You must be signed in to change notification settings - Fork 0
/
core_data_to-many_relationship_accessors.m
37 lines (34 loc) · 2.05 KB
/
core_data_to-many_relationship_accessors.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Core Data To-Many Relationship Accessors
// The add and remove methods for a to-many relationship.
//
// IDECodeSnippetCompletionPrefix:
// IDECodeSnippetCompletionScopes: [ClassImplementation]
// IDECodeSnippetIdentifier: C1E91503-E91F-4EEA-A032-D98D80CDD00A
// IDECodeSnippetLanguage: Xcode.SourceCodeLanguage.Objective-C
// IDECodeSnippetVersion: 1
- (void)add<#CapitalizedRelationshipName#>Object:(<#relationship destination class#> *)value
{
NSSet *changedObjects = [NSSet setWithObject:value];
[self willChangeValueForKey:@"<#relationshipName#>" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
[[self primitiveValueForKey:@"<#relationshipName#>"] addObject:value];
[self didChangeValueForKey:@"<#relationshipName#>" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
}
- (void)remove<#CapitalizedRelationshipName#>Object:(<#relationship destination class#> *)value
{
NSSet *changedObjects = [NSSet setWithObject:value];
[self willChangeValueForKey:@"<#relationshipName#>" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
[[self primitiveValueForKey:@"<#relationshipName#>"] removeObject:value];
[self didChangeValueForKey:@"<#relationshipName#>" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
}
- (void)add<#CapitalizedRelationshipName#>:(NSSet *)value
{
[self willChangeValueForKey:@"<#relationshipName#>" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
[[self primitiveValueForKey:@"<#relationshipName#>"] unionSet:value];
[self didChangeValueForKey:@"<#relationshipName#>" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
}
- (void)remove<#CapitalizedRelationshipName#>:(NSSet *)value
{
[self willChangeValueForKey:@"<#relationshipName#>" withSetMutation:NSKeyValueMinusSetMutation usingObjects:value];
[[self primitiveValueForKey:@"<#relationshipName#>"] minusSet:value];
[self didChangeValueForKey:@"<#relationshipName#>" withSetMutation:NSKeyValueMinusSetMutation usingObjects:value];
}