-
Notifications
You must be signed in to change notification settings - Fork 150
Global variable
Silver edited this page Aug 11, 2020
·
2 revisions
you can directly declare a gloabal var in scripts.
int value = 0;
NSString *string = "identifier";
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"];
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";
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;
}