Note that there are some explanatory texts on larger screens.

plurals
  1. PODouble quotes and NSPredicates
    primarykey
    data
    text
    <p>I am wondering why my predicates are having double quotes around the whatDateShouldEqual and the whatDateShouldEqual2 strings? is there a way to get rid of them in the predicate? I'm getting my predicate string equaling.</p> <blockquote> <p>"whatDateShouldEqual" >= CAST(378720000.000000, "NSDate");</p> </blockquote> <p>The double quotes are messing up my predicate.</p> <pre><code>//This method calls the function - (NSArray *) getAllTasksForCurrentYearForPieChart { NSArray *yearToDatePredicates = [self getPredicateForYearToDateFunctions:[NSString stringWithFormat:@"timeSheetDate"] secondPredicateFilterAtrribute:@"timeSheetDate"]; NSArray *allTimeSheets = [self getTimeSheetsWithEmployeeId:[NSNumber numberWithInt:[[CANetworkingManager sharedCANetworkingManager].employeeId intValue]]]; NSPredicate *predicate = [yearToDatePredicates objectAtIndex:0]; [allTimeSheets filteredArrayUsingPredicate:predicate]; predicate = [yearToDatePredicates objectAtIndex:1]; [allTimeSheets filteredArrayUsingPredicate:predicate]; NSArray *uniqueTaskIds = [self getAllUniqueTaskIDsBasedOnArrayOfTimeSheets:allTimeSheets]; NSArray *uniqueTasks = [self getTasks]; predicate = [NSPredicate predicateWithFormat:@"taskID IN %@", uniqueTaskIds]; uniqueTasks = [uniqueTasks filteredArrayUsingPredicate:predicate]; return uniqueTasks; } - (NSArray *) getPredicateForYearToDateFunctions: (NSString *) whatDateShouldEqual secondPredicateFilterAtrribute: (NSString *) whatDateShouldEqual2 { // This will get the task within the time area NSDateFormatter * df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"yyyy MM dd"]; NSDateComponents *components = [[NSCalendar currentCalendar] components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:[NSDate date]]; NSInteger year = [components year]; NSDate *firstDayOfYear = [df dateFromString:[NSString stringWithFormat:@"%d 01 01", year]]; NSDate *currentDayOfYear = [NSDate date]; NSMutableArray *holdBothPredicates = [NSMutableArray new]; [holdBothPredicates addObject:[NSPredicate predicateWithFormat:@"%@ &gt;= %@", whatDateShouldEqual, firstDayOfYear]]; [holdBothPredicates addObject:[NSPredicate predicateWithFormat:@"%@ &lt;= %@", whatDateShouldEqual2, currentDayOfYear]]; NSArray *turningToArray = [NSArray arrayWithArray:holdBothPredicates]; return turningToArray; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload