문제

I am able to fetch all messages using fetchMessagesByUIDOperationWithFolder:, however, message.flags all return 0 when some messages are unread, most are read and some are starred.

MCOIMAPMessagesRequestKind requestKind = MCOIMAPMessagesRequestKindHeaders;
NSString *folder = @"INBOX";
MCOIndexSet *uids = [MCOIndexSet indexSetWithRange:MCORangeMake(1, UINT64_MAX)];

MCOIMAPFetchMessagesOperation *fetchOperation = [session fetchMessagesByUIDOperationWithFolder:folder requestKind:requestKind uids:uids];
[fetchOperation start:^(NSError * error, NSArray * fetchedMessages, MCOIndexSet * vanishedMessages)
{
    if ( ! error )  {
        for ( MCOIMAPMessage * message_ in fetchedMessages )  {
           // I only want UNREAD messages.
        }
    }
}

I have tried using if ( message_.flags & MCOMessageFlagSeen ) but still, all flags return as 0.

What is the proper way to see if the message is UNREAD?

도움이 되었습니까?

해결책

For anyone having the same issue, you need to also include the kind request for flags: MCOIMAPMessagesRequestKindFlags.

MCOIMAPMessagesRequestKind requestKind = MCOIMAPMessagesRequestKindHeaders|MCOIMAPMessagesRequestKindFlags;

Then, look for the unread flag:

for ( MCOIMAPMessage * message_ in fetchedMessages )  {
    if ( message_.flags == 0 ) {
        // I have a suspicion that this is not the correct
        // way to do this, but it seems to work the way I need.
    }
}

다른 팁

You can use 0 or better as below, which is 0 too, but who knows if they decide to change it to something else later:

if(message_.flags == MCOMessageFlagNone)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top