From 9608a075af829e368478410f3a02b069b4631b1d Mon Sep 17 00:00:00 2001 From: iLem0n Date: Wed, 30 Mar 2016 11:50:05 +0200 Subject: [PATCH 1/6] Update RACSignal+ReactiveCoreData.h changed "where"-functions to make it usable in swift --- ReactiveCoreData/RACSignal+ReactiveCoreData.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ReactiveCoreData/RACSignal+ReactiveCoreData.h b/ReactiveCoreData/RACSignal+ReactiveCoreData.h index e3af8b6..9e33e69 100644 --- a/ReactiveCoreData/RACSignal+ReactiveCoreData.h +++ b/ReactiveCoreData/RACSignal+ReactiveCoreData.h @@ -26,7 +26,7 @@ - (RACSignal *)count; // Modifies NSFetchRequest to set predicate -- (RACSignal *)where:(id)predicateOrSignal; +- (RACSignal *)whereObjectMatches:(id)predicateOrSignal; // Returns a signal with NSFetchRequest's predicate modified according to format and its arguments // @@ -35,12 +35,12 @@ // Any new value in any of the argument signals will result in update of the fetch request // and possible execution of the request, if there's a `fetch` later. // This brings the predicates into the reactive world -- (RACSignal *)where:(NSString *)format args:(NSArray *)args; +- (RACSignal *)whereObjectMatches:(NSString *)format args:(NSArray *)args; // A convenience method for a common predicate case // // Create a "%K == %@" predicate with key and value as arguments -- (RACSignal *)where:(id)key equals:(id)value; +- (RACSignal *)whereObjectMatches:(id)key equals:(id)value; // A convenience method for a common predicate case // @@ -50,7 +50,7 @@ // This is useful when the using it to filter text from the search field, which can be empty // `options` parameter is an optional string like `@"cd"` that can be added after CONTAINS inside brackets. // For example, passing @"cd" for `options` will result in a CONTAINS[cd] predicate -- (RACSignal *)where:(id)key contains:(id)valueOrSignal options:(NSString *)optionsOrNil; +- (RACSignal *)whereObjectMatches:(id)key contains:(id)valueOrSignal options:(NSString *)optionsOrNil; // Modifies the NSFetchRequest to set passed-in limit - (RACSignal *)limit:(id)limitOrSignal; From 52c6fd6c406a5c76d7d95c948f592fa4fcf27d6c Mon Sep 17 00:00:00 2001 From: iLem0n Date: Wed, 30 Mar 2016 11:51:21 +0200 Subject: [PATCH 2/6] Update RACSignal+ReactiveCoreData.m changed "where"-functions to make it usable in swift --- ReactiveCoreData/RACSignal+ReactiveCoreData.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ReactiveCoreData/RACSignal+ReactiveCoreData.m b/ReactiveCoreData/RACSignal+ReactiveCoreData.m index e81eefd..3b42fc3 100644 --- a/ReactiveCoreData/RACSignal+ReactiveCoreData.m +++ b/ReactiveCoreData/RACSignal+ReactiveCoreData.m @@ -46,7 +46,7 @@ - (RACSignal *)count; #pragma mark - Operations modifying NSFetchRequest -- (RACSignal *)where:(id)predicateOrSignal; +- (RACSignal *)whereObjectMatches:(id)predicateOrSignal; { RACSignal *predicateSignal = [self rcd_convertToSignal:predicateOrSignal]; return [[[self combineLatestWith:predicateSignal] @@ -56,12 +56,12 @@ - (RACSignal *)where:(id)predicateOrSignal; }] setNameWithFormat:@"[%@] -where:%@", self.name, predicateOrSignal]; } -- (RACSignal *)where:(id)key equals:(id)value; +- (RACSignal *)whereObjectMatches:(id)key equals:(id)value; { return [self where:@"%K == %@" args:@[key, value]]; } -- (RACSignal *)where:(NSString *)format args:(NSArray *)args; +- (RACSignal *)whereObjectMatches:(NSString *)format args:(NSArray *)args; { NSArray *signals = [self rcd_convertToSignals:args]; return [[[self combineLatestWith:[RACSignal combineLatest:signals]] @@ -72,7 +72,7 @@ - (RACSignal *)where:(NSString *)format args:(NSArray *)args; }] setNameWithFormat:@"[%@] -where:%@ args:%@", self.name, format, args]; } -- (RACSignal *)where:(id)key contains:(id)valueOrSignal options:(NSString *)optionsOrNil; +- (RACSignal *)whereObjectMatches:(id)key contains:(id)valueOrSignal options:(NSString *)optionsOrNil; { NSParameterAssert(valueOrSignal); NSParameterAssert(key); From 503578a9c8d0d5c4fda0254c1bb2cca7a65f8dd7 Mon Sep 17 00:00:00 2001 From: iLem0n Date: Wed, 30 Mar 2016 11:59:19 +0200 Subject: [PATCH 3/6] Update RACSignal+ReactiveCoreData.m --- ReactiveCoreData/RACSignal+ReactiveCoreData.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReactiveCoreData/RACSignal+ReactiveCoreData.m b/ReactiveCoreData/RACSignal+ReactiveCoreData.m index 3b42fc3..8a48e96 100644 --- a/ReactiveCoreData/RACSignal+ReactiveCoreData.m +++ b/ReactiveCoreData/RACSignal+ReactiveCoreData.m @@ -58,7 +58,7 @@ - (RACSignal *)whereObjectMatches:(id)predicateOrSignal; - (RACSignal *)whereObjectMatches:(id)key equals:(id)value; { - return [self where:@"%K == %@" args:@[key, value]]; + return [self whereObjectMatches:@"%K == %@" args:@[key, value]]; } - (RACSignal *)whereObjectMatches:(NSString *)format args:(NSArray *)args; @@ -86,7 +86,7 @@ - (RACSignal *)whereObjectMatches:(id)key contains:(id)valueOrSignal options:(NS else { whereClause = @"%K CONTAINS %@"; } - return [self where:whereClause args:@[key, filter]]; + return [self whereObjectMatches:whereClause args:@[key, filter]]; } else return self; From fc3368e099b0d21870f94322e99bd5d6c6e18da7 Mon Sep 17 00:00:00 2001 From: iLem0n Date: Wed, 30 Mar 2016 16:58:10 +0200 Subject: [PATCH 4/6] Update NSManagedObject+ReactiveCoreData.m Changed +(String)entityName to work with NSmanagedObject subclasses in swift --- ReactiveCoreData/NSManagedObject+ReactiveCoreData.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactiveCoreData/NSManagedObject+ReactiveCoreData.m b/ReactiveCoreData/NSManagedObject+ReactiveCoreData.m index 62c5994..4c08606 100644 --- a/ReactiveCoreData/NSManagedObject+ReactiveCoreData.m +++ b/ReactiveCoreData/NSManagedObject+ReactiveCoreData.m @@ -35,7 +35,7 @@ + (RACSignal *)findOne; + (NSString *)entityName; { - return NSStringFromClass(self); + return [[NSStringFromClass(self) componentsSeparatedByString:@"."] lastObject]; } + (instancetype)insert; From ae13c00fa474ac01f5cecf86138e12c866250369 Mon Sep 17 00:00:00 2001 From: iLem0n Date: Wed, 30 Mar 2016 17:00:40 +0200 Subject: [PATCH 5/6] Update RACSignal+ReactiveCoreData.h Changed -(RACSignal *)where ... functions to make it usable in swift. Avoid overlap with keyword "where" --- ReactiveCoreData/RACSignal+ReactiveCoreData.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactiveCoreData/RACSignal+ReactiveCoreData.h b/ReactiveCoreData/RACSignal+ReactiveCoreData.h index 9e33e69..d80383a 100644 --- a/ReactiveCoreData/RACSignal+ReactiveCoreData.h +++ b/ReactiveCoreData/RACSignal+ReactiveCoreData.h @@ -27,7 +27,7 @@ // Modifies NSFetchRequest to set predicate - (RACSignal *)whereObjectMatches:(id)predicateOrSignal; - + // Returns a signal with NSFetchRequest's predicate modified according to format and its arguments // // The format is passed to NSPredicate as is From 8c2630ce08aaf37d3dd38b75e21134fe2bdeae49 Mon Sep 17 00:00:00 2001 From: iLem0n Date: Wed, 30 Mar 2016 17:01:17 +0200 Subject: [PATCH 6/6] Update RACSignal+ReactiveCoreData.m Changed -(RACSignal *)where ... functions to make it usable in swift. Avoid overlap with keyword "where" --- ReactiveCoreData/RACSignal+ReactiveCoreData.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactiveCoreData/RACSignal+ReactiveCoreData.m b/ReactiveCoreData/RACSignal+ReactiveCoreData.m index 8a48e96..d17bc86 100644 --- a/ReactiveCoreData/RACSignal+ReactiveCoreData.m +++ b/ReactiveCoreData/RACSignal+ReactiveCoreData.m @@ -18,7 +18,7 @@ - (RACSignal *)fetchInMOC:(NSManagedObjectContext *)moc; return [[moc executeRequest:req] map:^id(id value) { return [value lastObject]; }]; - } + } else { return [moc executeRequest:req]; }