We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sum a property:
func totalUnreadCount(whereParentChatId: String?) -> Int { let req = NSFetchRequest<NSDictionary>.init(entityName: Conversation.entityName()) if let parentChatId = whereParentChatId { req.predicate = NSPredicate.init(format: "parentChatId=%@", parentChatId) } else { req.predicate = NSPredicate.init(format: "parentChatId = nil") } let expressDescription = NSExpressionDescription.init() let express = NSExpression.init(format: "@sum.unreadCount") expressDescription.expression = express expressDescription.name = "total" expressDescription.expressionResultType = .integer32AttributeType req.propertiesToFetch = [expressDescription] req.resultType = .dictionaryResultType var count = 0 dbContext().performAndWait { let result = try? dbContext().fetch(req) if let total = result?.first?["total"] as? Int { count = total } } return count }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Sum a property:
The text was updated successfully, but these errors were encountered: