Hello everyone,
I've been trying to create an app that can transfer files between apps. I've successfully made an app to move pdf files in the iOS4 environment but I created an iOS5 app that uses the exact same code but it does not seem to work. Debugging is useless because it seems to not work between apps.
It opens up the "open with" popup like it should but which ever app you select, it just closes the popup and never starts the transfer. Does anyone know why this is happening? I put in logs to all the delegates but none get called.
I am started with pdfs as it is an existing UTI but eventually want to move over to a new UTI later. But I am not worrying about that right now.
Code:
@interface BExporter : NSObject <UIDocumentInteractionControllerDelegate> {
NSURL *bURL;
BOOL isValid;
UIView *parentView;
UIDocumentInteractionController *docController;
}
@property (strong, nonatomic) UIDocumentInteractionController *docController;
-(id) initWithURL:(NSURL *) tempURL inView:(UIView*) tempView;
-(BOOL) exportB;
-(void) openDocumentIn;
-(BOOL) isBValid;
-(BOOL) isBAvailable;
//UIDocumentInteractionController delegates
- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application;
- (void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application;
- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller;
Code:
@implementation BExporter
@synthesize docController = _docController;
-(id) initWithURL:(NSURL *) tempURL inView:(UIView*) tempView{
self = [super init];
if (self) {
bURL= tempURL;
parentView = tempView;
}
return self;
}
-(void)openDocumentIn {
NSString * filePath =
[[NSBundle mainBundle]
pathForResource:@"TheB" ofType:@"pdf"];
docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
docController.delegate = self;
//[docController retain];
[docController presentOpenInMenuFromRect:CGRectZero inView:parentView animated:YES];
}
-(BOOL) exportB {
docController = [UIDocumentInteractionController interactionControllerWithURL:bURL];
docController.delegate = self;
//[docController retain];
isValid = [docController presentOpenInMenuFromRect:CGRectZero inView:parentView animated:YES];
return isValid;
}
-(BOOL) isBValid{
//check to see if the b is valid
BOOL static checked = TRUE;
if (checked == TRUE) {
checked = TRUE;
}
return isValid;
}
- (BOOL)isBAvailable {
//check to see if there is a b app available
return (true);
}
#pragma UIDocumentInteractionController delegates
- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application{
NSLog(@"Starting Sending");
}
- (void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application{
NSLog(@"Finished Sending");
}
- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller{
NSLog(@"Dismiss Sending");
}
@end
Since this used to be iOS4 -> iOS5 I commented out the retains because of ARC and added the _docController to keep the link strong.
There are two actual ways to send the data in this code but they both fail the same way.
Please help.