探索flutter框架开发的app在移动应用市场的潜力与挑战
1768
2022-10-19
Mango是一种DSL,其语法与Objective-C非常相似,Mango也是iOS应用程序修补程序SDK
MangoFix中文资料集合
MangoFix 学习讨论QQ群:766215773
Mango
MangoFix is a DSL which syntax is very similar to Objective-C,MangoFix is also an iOS App hotfix SDK. You can use MangoFix method replace any Objective-C method.
Example
#import "AppDelegate.h"#import
class ViewController:UIViewController{- (UIView *)genView{ UIView *view = UIView.alloc().initWithFrame:(CGRectMake(50, 100, 150, 200)); view.backgroundColor = UIColor.redColor(); return view;}}
Installation
CocoaPods
Add pod 'MangoFix' to your Podfile.
Run pod install or pod update.Import
Usage
Objective-C
#import
MFContext *context = [[MFContext alloc] init];// exec mango file from network[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://xxx/demo.mg"]] queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) { NSString *script = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; [context evalMangoScriptWithSourceString:script];}]; // exec local mango fileNSString *sourcePath = [[NSBundle mainBundle] pathForResource:@"demo" ofType:@"mg"];NSString *script = [NSString stringWithContentsOfFile:sourcePath encoding:NSUTF8StringEncoding error:nil];[context evalMangoScriptWithSourceString:script];
Mango
Quick start
Mango Type usage
Mango support type as fllow:
void
equivalent to Objective-C `void`.
BOOL
equivalent to Objective-C `BOOL`.
uint
equivalent to Objective-C `unsigned char`、`unsigned short`、`unsigned int`、`unsigned long`、`unsigned long long`、`NSUInteger`.
int
equivalent to Objective-C `char`、`short`、`int`、`long`、`long long`、`NSInteger`.
double
equivalent to Objective-C `double`、`float`、`CGFloat`.
id
equivalent to Objective-C `id`.
OCClassName *
NSString *str = @"";
Block
Block blokc = ^id(id arg){};
Class
Class clazz = NSString.class();
struct
struct CGRect rect;// must add struct keyword before structure variables defined.
Pointer
Pointer ptr; // C pointer.
CFunction
CFunction
Ohter
For more information on MangFix usage, see the MangoFix project unit test.
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~