Created
September 12, 2011 21:42
-
-
Save AlanQuatermain/1212544 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSDictionary * args = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithDouble: self.pageRange.start], @"START", [NSNumber numberWithDouble: self.pageRange.end], @"END", self.contentItem.contentID, @"CONTENT_ID", [self.chapterInfo.destinationURL path], @"FILE_NAME", nil]; | |
static NSPredicate * template = nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
template = [[NSPredicate predicateWithFormat: @"(pageStartPercent BETWEEN {$START, $END} OR pageEndPercent BETWEEN {$START, $END}) AND SUBQUERY(chapter, $chapter, $chapter.contentID == $CONTENT_ID AND $chapter.chapterFileName == $FILE_NAME).@count > 0"] retain]; | |
}); | |
[myFetchRequest setPredicate: [template predicateWithSubstitutionVariables: args]]; | |
/* | |
(gdb) po template | |
(pageStartPercent BETWEEN {$START, $END} OR pageEndPercent BETWEEN {$START, $END}) AND SUBQUERY(chapter, $chapter, $chapter.contentID == $CONTENT_ID AND $chapter.chapterFileName == $FILE_NAME).@count > 0 | |
(gdb) po args | |
{ | |
"CONTENT_ID" = "99e6268c-362e-4e99-b37a-5a50e848dfd4"; | |
END = "0.08333333333333333"; | |
"FILE_NAME" = "/OEBPS/003-itr.html"; | |
START = 0; | |
} | |
(gdb) po [req predicate] | |
(pageStartPercent BETWEEN {0, 0.08333333333333333} OR pageEndPercent BETWEEN {0, 0.08333333333333333}) AND SUBQUERY(chapter, $chapter, $chapter.contentID == $CONTENT_ID AND $chapter.chapterFileName == $FILE_NAME).@count > 0 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment