ios 应用内启动另一个程序

void openNewApp(const char *text)
{
    NSString *url =[NSString stringWithUTF8String:text];
    url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];<span style="color:#ff0000;">//假如url内包含中文</span>
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

另一端接收解析数据

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
    
    NSString* text = [NSString stringWithFormat:@"%@",url];
    NSLog(@"%@",text);
    UIAlertView *alertView;
    NSString*text1 = [text stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    alertView = [[UIAlertView alloc] initWithTitle:@"Text---url=="
                                           message:text1
                                          delegate:nil
                                 cancelButtonTitle:@"OK"
                                 otherButtonTitles:nil];
    [alertView show];
    [alertView release];

    ClientGameUtils::sharedGameUtils()->params = const_cast<char*>([text1 cStringUsingEncoding:NSUTF8StringEncoding]) ;

    enter = YES;
    [self initGame];

    return YES;
}

bool CGameMessageScoket::InitClientKernel(string lpszComLine, CGameHandler * pGameHander)
{
    char str1[256] = {0};
//    const char *str2 = "OxEx://1/tablepassword/0/1/102/418/1199/7001/二人斗牛/二人牛牛1/508df4cb2f4d8f80519256258cfb975f";
    strcpy(str1 ,ClientGameUtils::sharedGameUtils()->params);
    const char *token = "/";
    strtok(str1, token);
    char* param1 =	strtok(NULL, token);
    char* param2 =	strtok(NULL, token);
    char* param3 =	strtok(NULL, token);
    char* param4 =	strtok(NULL, token);
    char* param5 =	strtok(NULL, token);
    char* param6 =	strtok(NULL, token);
    char* param7 =	strtok(NULL, token);
    char* param8 =	strtok(NULL, token);
    char* param9 =	strtok(NULL, token);
    char* param10 =	strtok(NULL, token);
    char* param11 =	strtok(NULL, token);
    CCLOG("%s--%s--%s--%s--%s--%s--%s--%s--%s--%s--%s--",param1,param2,param3,param4,param5,param6,param7,param8,param9,param10,param11);
	mClientUserInfo.dwUserID = atoi(param1);
	mClientUserInfo.lpszTablePassword = param2;
	mClientUserInfo.m_wReqChairID = atoi(param3);
	mClientUserInfo.m_wReqTableID = atoi(param4);
	mClientUserInfo.mKindID = atoi(param5);
	mClientUserInfo.wServerID = atoi(param6);
	mClientUserInfo.mServerIp = param7;
	mClientUserInfo.mServerPort = atoi(param8);
	ClientGameUtils::sharedGameUtils()->UTF8to16(mClientUserInfo.szKindName,param9);
	ClientGameUtils::sharedGameUtils()->UTF8to16(mClientUserInfo.szServerName,param10);
	ClientGameUtils::sharedGameUtils()->UTF8to16(mClientUserInfo.mLogonPassWord,param11);

	g_ClientKernel->m_pGameHandler = pGameHander;

	return true;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值