File tree 2 files changed +32
-3
lines changed
2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,28 @@ extern NSString* const constKeyNewValue ;
123
123
method in subclasses. The implementation simply returns super's owner.
124
124
@result The owner of the receiver
125
125
*/
126
- - (id )owner ;
126
+ - (id )owner ;
127
+
128
+ /* !
129
+ @brief Same as -owner, except returns the owner with a retain count of 1
130
+ that is not in the autorelease pool – the caller "owns" it
131
+
132
+ @details This method is recommended instead of -owner whenever the owner is
133
+ a transient object which may not be deallocced due to retain cycles with the
134
+ receiver. Keep in mind that Core Data can be quite anal-retentive:
135
+
136
+ https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CoreData/MO_Lifecycle.html
137
+
138
+ The reason for the prefix 'alloc' is that, of the four prefixes which
139
+ tell the clang objective-c static analyzer that this method returns an object
140
+ which the caller "owns", as explained here
141
+
142
+ https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html
143
+
144
+ 'alloc' is the least nonsensical for this case.
145
+ */
146
+
147
+ - (id )allocOwner ;
127
148
128
149
/* !
129
150
@brief Returns whether or not a retained managed object is
Original file line number Diff line number Diff line change @@ -222,6 +222,16 @@ - (id)owner {
222
222
return [SSYMOCManager ownerOfManagedObjectContext: [self managedObjectContext ]] ;
223
223
}
224
224
225
+ - (id )allocOwner {
226
+ id owner;
227
+ @autoreleasepool {
228
+ owner = [SSYMOCManager ownerOfManagedObjectContext: [self managedObjectContext ]];
229
+ [owner retain ];
230
+ }
231
+
232
+ return owner;
233
+ }
234
+
225
235
- (BOOL )isAvailable {
226
236
if ([self isDeleted ]) {
227
237
return NO ;
@@ -498,10 +508,8 @@ - (NSUInteger)countOfNonNilValues {
498
508
#warning Testing snapshot events
499
509
500
510
+ (NSCountedSet*)awakenedObjects {
501
- NSCountedSet* awakenedObjects = ssyDebugGlobalObject ;
502
511
if (!awakenedObjects) {
503
512
awakenedObjects = [[NSCountedSet alloc] init] ;
504
- ssyDebugGlobalObject = awakenedObjects ;
505
513
NSLog(@"awakenedObjects = %p", awakenedObjects) ;
506
514
}
507
515
You can’t perform that action at this time.
0 commit comments