diff --git a/mogenerator.m b/mogenerator.m index e2b786f..7d7a5f3 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -442,13 +442,23 @@ - (NSArray*)prettyFetchRequests { @implementation NSAttributeDescription (typing) - (BOOL)isUnsigned { - BOOL hasMin = NO; + BOOL isUnsigned = NO; for (NSPredicate *pred in [self validationPredicates]) { - if ([pred.predicateFormat containsString:@">= 0"]) { - hasMin = YES; + NSString* formatString = pred.predicateFormat; + NSRange range = [formatString rangeOfString:@"SELF >="]; + if (range.location != NSNotFound) { + NSUInteger startIndex = range.location + range.length; + NSString *minString = [formatString substringFromIndex:startIndex]; + NSScanner *scanner = [NSScanner scannerWithString:minString]; + NSInteger minValue; + BOOL success = [scanner scanInteger:&minValue]; + if (success && (minValue >= 0)) { + isUnsigned = YES; + break; + } } } - return hasMin; + return isUnsigned; } - (BOOL)hasScalarAttributeType {