Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tutorials > Tutorial Requests

Reply
 
LinkBack Thread Tools Display Modes
Old 11-04-2011, 10:38 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Location: Toronto
Posts: 23
Darkin is on a distinguished road
Question creating UTI to transfer files between apps

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.
Darkin is offline   Reply With Quote
Old 11-04-2011, 01:00 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2009
Location: Toronto
Posts: 23
Darkin is on a distinguished road
Default odd

I seemed to get it to work by moving the methods out of the NSObject I created for it and putting it directly in the ViewController I was using it on. Not sure why since it worked fine before...
Darkin is offline   Reply With Quote
Reply

Bookmarks

Tags
arc, document, ios5, transfer, uti

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 175,696
Threads: 94,139
Posts: 402,963
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jasper_muc
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:16 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0