Note that there are some explanatory texts on larger screens.

plurals
  1. POFetch distinct data from Core data alongwith descending order?
    primarykey
    data
    text
    <p>I creating chat app in which i save data in core data. I using following entity,</p> <p><img src="https://i.stack.imgur.com/lMq7u.png" alt="enter image description here"></p> <p>I want to fetch data all unique <code>customerno</code> and that data will be descending order of <code>messagedate</code> also contain latest <code>messagetext</code> which send from other <code>cmid</code>. I want to show list <em>like facebook chat message list and smiler view</em>. I trying following code ,</p> <pre><code>-(NSArray *)getAllInstanceMessages{ NSError *error = nil; NSFetchRequest * req = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"IMDetails" inManagedObjectContext:theManageContext]; [req setPredicate:[NSPredicate predicateWithFormat:@"cmid=%@", theCmID]]; NSDictionary *entityProperties = [entity propertiesByName]; [req setEntity:entity]; [req setReturnsDistinctResults:YES]; [req setResultType:NSDictionaryResultType]; [req setPropertiesToFetch:[NSArray arrayWithObject:[entityProperties objectForKey:@"customerno"]]]; [req setSortDescriptors:[NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"messagedate" ascending:NO]]]; NSArray *result = [theManageContext executeFetchRequest:req error:&amp;error]; if(error){ NSLog(@"%s, %@", __FUNCTION__, [error localizedDescription]); return nil; } return result; } </code></pre> <p>the above code given my following output,</p> <pre><code>Printing description of result: &lt;_PFArray 0xa3cda70&gt;( { customerno = CN00001; customerno = CN00002; customerno = CN00003; } ) </code></pre> <p>I want complete data along with this unique numbers, i mean array of dictionary/ManagedObject containing unique data suppose in above CN0001 number but it doesn't contain other attributes values. </p> <p>what i do wrong in code?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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