는 모든 응용 프로그램에 URL을 열려면 당신은 발사 서비스를 사용할 수 있습니다. 보고 싶은 기능은 LSOpenURLsWithRole
입니다.
편집 :
당신은 사용할 수 있습니다이 방법에 대한 귀하의 프로젝트에에서 SystemConfiguration 프레임 워크를 연결해야합니다.
애플 문서 참조
here 예를 들어
당신이 사파리와 http://www.google.com
를 열려면 :
//the url
CFURLRef url = (__bridge CFURLRef)[NSURL URLWithString:@"http://www.google.com"];
//the application
NSString *fileString = @"/Applications/Safari.app/";
//create an FSRef of the application
FSRef appFSURL;
OSStatus stat2=FSPathMakeRef((const UInt8 *)[fileString UTF8String], &appFSURL, NULL);
if (stat2<0) {
NSLog(@"Something wrong: %d",stat2);
}
//create the application parameters structure
LSApplicationParameters appParam;
appParam.version = 0; //should always be zero
appParam.flags = kLSLaunchDefaults; //use the default launch options
appParam.application = &appFSURL; //pass in the reference of applications FSRef
//More info on params below can be found in Launch Services reference
appParam.argv = NULL;
appParam.environment = NULL;
appParam.asyncLaunchRefCon = NULL;
appParam.initialEvent = NULL;
//array of urls to be opened - in this case a single object array
CFArrayRef array = (__bridge CFArrayRef)[NSArray arrayWithObject:(__bridge id)url];
//open the url with the application
OSStatus stat = LSOpenURLsWithRole(array, kLSRolesAll, NULL, &appParam, NULL, 0);
//kLSRolesAll - the role with which the applicaiton is to be opened (kLSRolesAll accepts any)
if (stat<0) {
NSLog(@"Something wrong: %d",stat);
}
대기중인 파일 : ///은 URL을 여는 동안 열려 있지 않으므로 url이 아닙니다. – Varun
업데이트 된 답변을 확인하십시오, 지금 작동합니다. – Neha
예! 그것은 굉장! – Genevios