I have an attribute called uuid that is of type UUID in my Core Data Entity. I'm then subsequently using an NSString representation to search for that UUID using an NSPredicate.
Please note I'm using Objective C, not Swift here.
When I use the following predicate everything works.
NSString *uuid = @"fa96efec-7c33-463e-8ce9-a9463c469d24";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"uuid == %@", [[NSUUID alloc] initWithUUIDString:uuid]];
However if I end up making a lot of calls this could be extremely memory intensive and seems like a wasted step creating an NSUUID each time...
Everything I've found online states to do it this way...
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"uuid.UUIDString == [c] %@", uuid];
However this results in an EXC_BAD_ACCESS (code=1) crash. There is nothing in the log indicating why either. I just managed to track it down to the executeFetchRequest call with the predicate set.
Which is the proper way of doing this without wasting memory creating NSUUIDs? I realize they are tiny but still, it seems like poor code.