I already solved my problem [Blindly], not understanding the root cause. But I would rather understand the concept of a professional. Could you tell me why below the identical code works and the other does not.
Code 1: not working
//Above code omitted... NSPredicate * predicate = [NSPredicate predicateWithFormat:@"gender == m"]; //NOTICE HERE [request setPredicate:predicate]; NSError *error = nil; self.people = [self.managedObjectContext executeFetchRequest:request error:&error]; //Below code omitted...
Code 2: Does it work
//Above code omitted... NSString *type = @"m"; NSPredicate * predicate = [NSPredicate predicateWithFormat:@"gender == %@",type]; //NOTICE HERE [request setPredicate:predicate]; NSError *error = nil; self.people = [self.managedObjectContext executeFetchRequest:request error:&error]; //Below code omitted...
I forgot to talk about what error I got, I got SIGABRT in the line below, When I executed code 1.
self.people = [self.managedObjectContext executeFetchRequest:request error:&error];
And one more thing: in a GCC error, he could not format the predicate due to "gender == m".
Enlighten me!
thanks
source share