-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlbum+methods.m
37 lines (30 loc) · 996 Bytes
/
Album+methods.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
//
// Album+methods.m
// Calculator
//
// Created by Corey Allen Pett on 11/11/15.
// Copyright © 2015 Corey Allen Pett. All rights reserved.
//
#import "Album+methods.h"
@implementation Album (methods)
//CoreData has a bug when checking "Ordered" in your data model. It crashed my program when adding a photo object to an album.
//Below is the workaround solution
- (void)addPhotosObject:(Photo *)value
{
NSMutableOrderedSet *photos = [[NSMutableOrderedSet alloc] initWithOrderedSet:self.photos];
[photos addObject:value];
self.photos = photos;
}
- (void)removePhotosObject:(Photo *)value
{
NSMutableOrderedSet *photos = [[NSMutableOrderedSet alloc] initWithOrderedSet:self.photos];
[photos removeObject:value];
self.photos = photos;
}
- (void)removeObjectFromPhotosAtIndex:(NSUInteger)idx
{
NSMutableOrderedSet *photos = [[NSMutableOrderedSet alloc] initWithOrderedSet:self.photos];
[photos removeObjectAtIndex:idx];
self.photos = photos;
}
@end