选择不同的coredata ios

时间:2015-08-22 02:29:38

标签: ios core-data

我希望select distinct结果lastobject找到distinctCoreData没有重复!!!

我在iOS中使用select distinct * from table ,并希望使用谓词来选择不同的结果。我的SQL查询就像:

-(NSMutableArray *) getResults :(NSString *)entity
{
    NSManagedObjectContext *managedObjectContext = [self managedObjectContext];
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:entity];

//    [fetchRequest setResultType:NSDictionaryResultType];
//    [fetchRequest setReturnsDistinctResults:YES];

    NSMutableArray *result = [[managedObjectContext executeFetchRequest:fetchRequest error:nil] mutableCopy];
    return result;
}

我的获取功能:

lastobject

如何从结果中获得distinctPrivate Sub BottomToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BottomToolStripMenuItem.Click If ColorDialog2.ShowDialog() = DialogResult.OK Then Dim bottombackgroundColor As Color = ColorDialog2.Color My.Settings.BottomBackgroundColor = bottombackgroundColor Me.TabPage1.BackColor = ColorDialog2.Color Me.TabPage2.BackColor = ColorDialog2.Color Me.TabPage3.BackColor = ColorDialog2.Color Me.TabPage4.BackColor = ColorDialog2.Color Me.TabPage5.BackColor = ColorDialog2.Color Me.Password.BackColor = ColorDialog2.Color Me.Remote.BackColor = ColorDialog2.Color Me.IE.BackColor = ColorDialog2.Color Me.Ticket.BackColor = ColorDialog2.Color Me.Helpdesk.BackColor = ColorDialog2.Color frmAbout.BackColor = ColorDialog2.Color frmCheckStatus.BackColor = ColorDialog2.Color frmError.BackColor = ColorDialog2.Color frmGroups.BackColor = ColorDialog2.Color frmLockout.BackColor = ColorDialog2.Color frmNetUser.BackColor = ColorDialog2.Color frmPassGen.BackColor = ColorDialog2.Color frmPreferences.BackColor = ColorDialog2.Color frmServerFind.BackColor = ColorDialog2.Color frmTicketHelper.BackColor = ColorDialog2.Color frmUpdate.BackColor = ColorDialog2.Color frmUserSearch.BackColor = ColorDialog2.Color My.Settings.Save() End If End Sub 结果。

0 个答案:

没有答案