What I am doing to fetch the data for core data is following
NSString *str;
NSPredicate *predicate;
switch (typeCube) {
case NewCubes: {
str = [NSString stringWithFormat:@"type == %d",NewCubes];
break;
}
case AllCubes: {
str = [NSString stringWithFormat:@"type != %d",CustomCubes];
break;
}
case CustomCubes: {
str = [NSString stringWithFormat:@"type == %d",CustomCubes];
break;
}
}
predicate = [NSPredicate predicateWithFormat:@"%@ AND (accounts.keyChainId == %@)", str, accountKeyChainId];
However, the result of predicate is nil. But the following works
predicate = [NSPredicate predicateWithFormat:@"(type == %d) AND (accounts.keyChainId == %@)", type, accountKeyChainId]; ( type is either NewCubes or AllCubes or CustomCubes)
Please help if you have any ideas. All comments are welcomed. Thanks