iPhone应用程序间传递参数两种方法

方法1:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions方法中,参数字典launchOptions包含了调用该函数的应用名称(UIApplicationLaunchOptionsSourceApplicationKey)和URL(UIApplicationLaunchOptionsURLKey)

 //处理应用程序间信息共享
if (launchOptions) {
NSString *sourceApp = [launchOptions objectForKey:UIApplicationLaunchOptionsSourceApplicationKey];

   NSURL * urlToOpen = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];

    if (urlToOpen != nil)

{}


}


方法2:


/*
*响应其他应用程序通过URL方案来调用该程序时的方法
*/
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{

NSString * urlToOpen = [NSString stringWithFormat:@"%@",url];

return YES;
}

你可能感兴趣的:(IOS)