如何使用两个以上的表达式搜索mailcore2?
下面的示例包括exprSinceLastTime以及exprFrom和exprSubject。但是,searchAdd只有两个参数的空间。
如何添加其他搜索表达式,例如exprSinceLastTime?
NSTimeInterval oneHour = 3600;
NSDate *now = [NSDate dateWithTimeIntervalSinceNow:oneHour];
MCOIMAPSearchExpression * exprSinceLastTime = [MCOIMAPSearchExpression searchSinceReceivedDate:now];
MCOIMAPSearchExpression * exprFrom = [MCOIMAPSearchExpression searchFrom: @"apple"];
MCOIMAPSearchExpression * exprSubject = [MCOIMAPSearchExpression searchSubject: @"cloudkit"];
MCOIMAPSearchExpression * expr = [MCOIMAPSearchExpression searchAnd: exprFrom other: exprSubject];
MCOIMAPSearchOperation* searchOperation = [session searchExpressionOperationWithFolder: folder expression: expr];
答案 0 :(得分:2)
我发布以下答案。这很简单。我不得不在这个问题上睡觉,想到明显的答案: - )
NSTimeInterval oneHour = 3600; // magic number! 60 seconds
NSDate *now = [NSDate dateWithTimeIntervalSinceNow:oneHour];
MCOIMAPSearchExpression * exprSinceLastTime = [MCOIMAPSearchExpression searchSinceReceivedDate:now];
MCOIMAPSearchExpression* exprFrom = [MCOIMAPSearchExpression searchFrom: @"youtube"];
MCOIMAPSearchExpression* exprSubject = [MCOIMAPSearchExpression searchSubject: @"video"];
MCOIMAPSearchExpression* expr = [MCOIMAPSearchExpression searchAnd: exprFrom other: exprSubject];
MCOIMAPSearchExpression* expr2 = [MCOIMAPSearchExpression searchAnd: exprSinceLastTime other: expr];
MCOIMAPSearchOperation* searchOperation = [session searchExpressionOperationWithFolder: folder expression: expr2];