i'm using realmswift , have realm object called book
book ===== title: string pagecount: int when app starts books using:
allbooks = realm.objects(book) a book has realm property called pagecount
i'm trying understand how can total pages count books?
so if have book 3 pages, book b 11 pages , book c 0 pages total count 3+11+0 = 14
i préfère doing query , not iterate through books
you can total number of pages book objects follows:
let totalpages: int = realm.objects(book).sum("pagecount")
Comments
Post a Comment