Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In _NSStringPathScale function ,"result.range.location >= 3" should be "result.range.length >= 3". #141

Open
tongyuhu opened this issue Jun 5, 2019 · 0 comments

Comments

@tongyuhu
Copy link

tongyuhu commented Jun 5, 2019

static CGFloat _NSStringPathScale(NSString *string) {
if (string.length == 0 || [string hasSuffix:@"/"]) return 1;
NSString *name = string.stringByDeletingPathExtension;
__block CGFloat scale = 1;

NSRegularExpression *pattern = [NSRegularExpression regularExpressionWithPattern:@"@[0-9]+\\.?[0-9]*x$" options:NSRegularExpressionAnchorsMatchLines error:nil];
[pattern enumerateMatchesInString:name options:kNilOptions range:NSMakeRange(0, name.length) usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
    if (result.range.location >= 3) {
        scale = [string substringWithRange:NSMakeRange(result.range.location + 1, result.range.length - 2)].doubleValue;
    }
}];

return scale;

}

return 2 when pass icon@2x.png, but return 1 when pass ic@2x.png.
so "result.range.location >= 3" should be "result.range.length >= 3"

@tongyuhu tongyuhu changed the title In_NSStringPathScale function,It should be "result.range.location >= 3" ,It should be "result.range.length >= 3". In_NSStringPathScale function ,"result.range.location >= 3" should be "result.range.length >= 3". Jun 5, 2019
@tongyuhu tongyuhu changed the title In_NSStringPathScale function ,"result.range.location >= 3" should be "result.range.length >= 3". In _NSStringPathScale function ,"result.range.location >= 3" should be "result.range.length >= 3". Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant