우리는 두 응용 프로그램에 응용 프로그램 간 통신을 사용하고 하나의 응용 프로그램에서 다른 응용 프로그램으로 파일 경로를 보내려고합니다. 문제는 보낸 사람 응용 프로그램을 통해 어떤 텍스트를 수신기로 전달하면 제대로 작동한다는 것입니다. 그렇지 수신기 측에서 보낸다른 앱의 문서 폴더에 앱이 액세스 할 수없는 이유는 무엇입니까?
-(IBAction) openReceiverApp:(id)sender {
// Opens the Receiver app if installed, otherwise displays an error
UIApplication *ourApplication = [UIApplication sharedApplication];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory, @"ads.rtf"];
NSLog(@"filePath %@", filePath);
// NSString *URLEncodedText = [self.textBox.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *URLEncodedText = [filePath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *ourPath = [@"readtext://" stringByAppendingString:URLEncodedText];
NSLog(@"%@",ourPath);
NSURL *ourURL = [NSURL URLWithString:ourPath];
if ([ourApplication canOpenURL:ourURL]) {
[ourApplication openURL:ourURL];
}
else {
//Display error
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Receiver Not Found" message:@"The Receiver App is not installed. It must be installed to send text." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
내 코드는 내가이 코드
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
// Display text
UIAlertView *alertView;
NSString *text = [[url host]stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
alertView = [[UIAlertView alloc] initWithTitle:@"Text" message:text delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
return YES;
를 작성했습니다 여기 작동 않는 한 다음 파일 문서 경로를 통과 나는 내가 잘못 아무데도 ?? 미리 감사드립니다 ....
샌드 박스. 각 앱은 자체 컨테이너 폴더에 독점적으로 액세스 할 수 있습니다. – trojanfoe
다른 응용 프로그램 파일에 액세스하고 싶지 않습니다. 내 응용 프로그램에서 다른 응용 프로그램으로 파일 하나만 전송하려고합니다. –
코드는 한 응용 프로그램에서 다른 응용 프로그램으로 파일 이름을 전달하려고하는 것을 보여줍니다. 그건 효과가 없으며 다른 기술을 사용해야 할 것입니다. – trojanfoe