Skip to content

Repository files navigation

YTXModule

Example

In .m

YTXMODULE_EXTERN()
{
//This is load
isLoad = YES;
}
//check userInfo/completion should be nilYTXMODULE_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:selfwithSelector:@selector(testRegisterTargetSelector)];
testRegisterTargetSelector = [YTXModule objectForURL:@"YTX://Test/targetSelector"];
returnYES;
}
- (void)viewWillAppear:(BOOL)animated
{
[superviewWillAppear:animated];
[YTXModule registerAppDelegateObject:self];
}
- (void)viewDidDisappear:(BOOL)animated
{
[superviewDidDisappear: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, 78612846@qq.com

License

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

About

YTXModule supports widget communication with URL and register application life by easy way.This is an easy and important library for widgetify.

Topics

Resources

Stars

73 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages