Skip to content

MR_executeFetchRequestAndReturnFirstObject with [request setResultType:NSDictionaryResultType] leads to compiler warning #1396

@donnerluetjen

Description

@donnerluetjen

In NSManagedObject+MagicalAggregation the method MR_aggregateOperation has the following lines:

NSFetchRequest *request = [self MR_requestAllWithPredicate:predicate inContext:context];
    [request setPropertiesToFetch:properties];
    [request setResultType:NSDictionaryResultType];    
    
    NSDictionary *resultsDictionary = [self MR_executeFetchRequestAndReturnFirstObject:request inContext:context];

This results in a compiler warning
Incompatible pointer types initializing 'NSDictionary *' with an expression of type 'NSManagedObject * _Nullable'
because the compiler does not know about the set result type.

I think the call here needs an explicit type cast, like so
NSDictionary *resultsDictionary = (NSDictionary *)[self MR_executeFetchRequestAndReturnFirstObject:request inContext:context];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions