-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore_data_to-many_relationship_accessors.m
38 lines (35 loc) · 2.08 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
38
// Core Data To-Many Relationship Accessors
// The add and remove methods for a to-many relationship.
//
// IDECodeSnippetCompletionPrefix:
// IDECodeSnippetCompletionScopes: [ClassImplementation]
// IDECodeSnippetIdentifier: 25A7E83C-FE80-43D3-A257-3F62C4A944D2
// IDECodeSnippetLanguage: Xcode.SourceCodeLanguage.Objective-C
// IDECodeSnippetUserSnippet: 1
// IDECodeSnippetVersion: 2
- (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];
}