Tôi đã sau mã cho lấy và nhóm kết quả tìm kiếm:Các thuộc tính NSFetchRequest có thể là Nhóm không phân biệt chữ hoa chữ thường không?
NSFetchRequest *request = [[NSFetchRequest alloc] initWithEntityName:@"Song"];
[request setPredicate:[NSCompoundPredicate andPredicateWithSubpredicates:predicates]];
[request setResultType:NSDictionaryResultType];
[request setSortDescriptors: @[[NSSortDescriptor sortDescriptorWithKey:@"timestamp" ascending:YES]]];
NSExpression *countExpression = [NSExpression expressionWithFormat:@"count:(SELF)"];
NSExpressionDescription *expressionDescriprion = [[NSExpressionDescription alloc] init];
[expressionDescriprion setName:@"count"];
[expressionDescriprion setExpression:countExpression];
[expressionDescriprion setExpressionResultType:NSInteger64AttributeType];
NSArray *properties = @[@"artistName", @"songName"];
[request setPropertiesToFetch:[properties arrayByAddingObject:expressionDescriprion]];
[request setPropertiesToGroupBy:properties];
self.fetchedItems = [self.managedObjectContext executeFetchRequest:request error:nil];
mà hoạt động rất đẹp, nhưng tôi phải đối mặt với phát hành và loại stucked với, vì vậy tôi cần phải thực hiện propertiesToGroupBy này (loại tài sản được NSString *) trường hợp không nhạy cảm bằng cách nào đó. Tại thời điểm Tôi đã theo sản lượng:
<_PFArray 0x7fa3e3ed0d90>(
{
artistName = "System of a Down";
count = 44;
songName = "Lonely Day";
},
{
artistName = "System Of A Down";
count = 2;
songName = "Lonely Day";
},
{
artistName = "System of a Down";
count = 4;
songName = "Chop Suey";
}
)
đó là không chính xác, vì vậy tôi cần 2 mục đầu tiên là trong phần duy nhất, gây ra điều này là các nghệ sĩ cùng.
Có cách nào để đạt được điều đó không?
Điều đó dường như không thể nhóm bởi NSExpressionDescription cho tôi. Sau [yêu cầu setPropertiesToGroupBy: myExpressions]; Tôi luôn có 'NSInvalidArgumentException', lý do: 'Biểu thức phím tắt không hợp lệ – iiFreeman