YTXModule 1.2.6

YTXModule 1.2.6

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Apr 2018

Maintained by CaoJun.



YTXModule 1.2.6

  • By
  • caojun

YTXModule

Example

In .m

YTXMODULE_EXTERN()
{
    //This is load
    isLoad = YES;
}

//check userInfo/completion should be nil

YTXMODULE_EXTERN_ROUTER_METHOD(@"URL")
{
    YTXMODULE_EXAPAND_PARAMETERS(parameters)
    NSLog(@"%@ %@", userInfo, completion);
    isCallRouterMacro1 = YES;
    completionExits = completion;
    userInfoExits = userInfo;
    completion(@"Success");
}

YTXMODULE_EXTERN_ROUTER_OBJECT_METHOD(@"object")
{
    YTXMODULE_EXAPAND_PARAMETERS(parameters)
    NSLog(@"%@ %@", userInfo, completion);
    isCallRouterObjectMacro1 = YES;
    completionExits1 = completion;
    userInfoExits1 = userInfo;
    return @"我是个类型";
}

YTXMODULE_EXTERN_ROUTER_METHOD(@"YTX://QUERY/:query")
{
    YTXMODULE_EXAPAND_PARAMETERS(parameters)
    NSLog(@"%@ %@", userInfo, completion);
    
    testQueryStringQueryValue = parameters[@"query"];;
    testQueryStringNameValue = parameters[@"name"];
    testQueryStringAgeValue = parameters[@"age"];
}

other .m

[YTXModule openURL:@"URL" withUserInfo:@{@"Test":@1} completion:^(id result) {
    NSLog(@"completion:%@", result);
}];

NSString * testObject1 = [YTXModule objectForURL:@"object" withUserInfo:@{@"Test":@1}];

[YTXModule openURL:@"YTX://QUERY/query?age=18&name=CJ"];

Application life. Support all application life.

YTXMODULE_EXTERN()
{
    
}
+ (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions
{
    applicationLifCycle1 = YES;
    [YTXModule registerURLPattern:@"YTX://Test/targetSelector" withTarget:self withSelector:@selector(testRegisterTargetSelector)];
    testRegisterTargetSelector = [YTXModule objectForURL:@"YTX://Test/targetSelector"];
    return YES;
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [YTXModule registerAppDelegateObject:self];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [YTXModule unregisterAppDelegateObject:self];
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    NSLog(@"Receive BecomeActive");
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    NSLog(@"Receive ResignActive");
}

More infomation, please check test case

Requirements

Installation

YTXModule is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "YTXModule"

Author

caojun, [email protected]

License

YTXModule is available under the MIT license. See the LICENSE file for more info.