Skip to content

Instantly share code, notes, and snippets.

@tomblench
Created June 25, 2018 13:38
Show Gist options
  • Save tomblench/82f493fe0bb377caa42372249a4c6f72 to your computer and use it in GitHub Desktop.
Save tomblench/82f493fe0bb377caa42372249a4c6f72 to your computer and use it in GitHub Desktop.
diff --git a/CDTDatastore/query/CDTDatastore+Query.m b/CDTDatastore/query/CDTDatastore+Query.m
index 3ca9beb..a3ee2a2 100644
--- a/CDTDatastore/query/CDTDatastore+Query.m
+++ b/CDTDatastore/query/CDTDatastore+Query.m
@@ -31,7 +31,7 @@
// constructed. This association is cleared in
// [CDTQIndexManager dealloc].
objc_setAssociatedObject(self, @selector(CDTQManager), m,
- OBJC_ASSOCIATION_ASSIGN);
+ OBJC_ASSOCIATION_RETAIN);
}
}
diff --git a/CDTDatastore/query/CDTQIndexManager.h b/CDTDatastore/query/CDTQIndexManager.h
index 12d5158..6d69f1e 100644
--- a/CDTDatastore/query/CDTQIndexManager.h
+++ b/CDTDatastore/query/CDTQIndexManager.h
@@ -85,7 +85,7 @@ typedef NS_ENUM(NSInteger, CDTQQueryError) {
*/
@interface CDTQIndexManager : NSObject
-@property (nonatomic, strong) CDTDatastore *datastore;
+@property (nonatomic, weak) CDTDatastore *datastore;
@property (nonatomic, strong) FMDatabaseQueue *database;
@property (nonatomic, readonly, getter = isTextSearchEnabled) BOOL textSearchEnabled;
diff --git a/CDTDatastore/query/CDTQIndexManager.m b/CDTDatastore/query/CDTQIndexManager.m
index 2f9fe38..28fffa0 100644
--- a/CDTDatastore/query/CDTQIndexManager.m
+++ b/CDTDatastore/query/CDTQIndexManager.m
@@ -128,10 +128,6 @@ static const int VERSION = 2;
{
// close the database.
[self.database close];
- // remove the datastore's association with us, otherwise it will
- // become invalid since it's a weak reference
- objc_setAssociatedObject(self.datastore, @selector(CDTQManager), nil,
- OBJC_ASSOCIATION_ASSIGN);
}
#pragma mark List indexes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment