3
我有我認爲在Google-verse上很容易找到/找到的東西,但一直都很困惑。我有一個在Core Data中設置了兩個日期屬性的對象。我想獲取兩個日期不同的對象列表。我如何使用核心數據來做到這一點?NSPredicate - 核心數據 - 將兩個屬性互相比較
[NSPredicate predicateWithFormat:@"dateModified != dateCreated"];
不起作用。
我有我認爲在Google-verse上很容易找到/找到的東西,但一直都很困惑。我有一個在Core Data中設置了兩個日期屬性的對象。我想獲取兩個日期不同的對象列表。我如何使用核心數據來做到這一點?NSPredicate - 核心數據 - 將兩個屬性互相比較
[NSPredicate predicateWithFormat:@"dateModified != dateCreated"];
不起作用。
您正在使用的格式是搜索鍵值關係,但雙方都有鍵,dateModified
和dateCreated
。嘗試這樣的:
[NSPredicate predicateWithFormat:@"(dateModified != %@)", someObject.dateCreated]
這應該工作得很好。它以什麼方式「不起作用」? – zpasternack