Skip to content

Global variable

Silver edited this page Aug 11, 2020 · 2 revisions

If Have a clear value.

you can directly declare a gloabal var in scripts.

int value = 0;
NSString *string = "identifier";

Pre-compile function

Example: dispatch_once. you shoul do like this.

// In Applicatoin file
[MFScopeChain.topScope setValue:[MFValue valueWithBlock:^void(dispatch_once_t *onceTokenPtr,
                                                              dispatch_block_t _Nullable handler){
    dispatch_once(onceTokenPtr,handler);
}] withIndentifier:@"dispatch_once"];

Static variable

Example: NSForegroundColorAttributeName.

Way 1:

// In Applicatoin file
[MFScopeChain.topScope setValue:[MFValue valueWithObject:NSForegroundColorAttributeName] withIndentifier:@"NSForegroundColorAttributeName"];

Way 2:

// NSLog(@"%@",NSForegroundColorAttributeName) Result is: "NSColor"
// In Scripts
NSString *NSForegroundColorAttributeName = @"NSColor";

Customize C Function

In Scrtips:

CGRect CGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
{
  CGRect rect;
  rect.origin.x = x; rect.origin.y = y;
  rect.size.width = width; rect.size.height = height;
  return rect;
}
Clone this wiki locally