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

Process error with Objective-C block #365

Open
kingsword opened this issue Nov 24, 2022 · 0 comments
Open

Process error with Objective-C block #365

kingsword opened this issue Nov 24, 2022 · 0 comments

Comments

@kingsword
Copy link

@implementation TestLizard
+ (UIImage *)sgb_imageWithSize:(CGSize)size drawBlock:(void (^)(CGContextRef context))drawBlock {
    if (!drawBlock) return nil;
    UIGraphicsBeginImageContextWithOptions(size, NO, 0);
    CGContextRef context = UIGraphicsGetCurrentContext();
    if (!context) return nil;
    drawBlock(context);
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}
@end

deal with the code above, and get result:

Function name -> `sgb_imageWithSize: drawBlock: CGContextRef.image`,
Cyclomatic complexity -> 1
LOC -> 2

but in fact,

function name -> `sgb_imageWithSize: drawBlock:`
Cyclomatic complexity -> 3
LOC -> 10

https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html

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