I'm having trouble trying to open a file.
I download a document file somewhere, and I have a viewer to view the file on my iPhone. I want my app to open the file to the viewer.
Here's what I'm trying to do in -(IBAction)buttonPressed:
dc = [UIDocumentInteractionController interactionControllerWithURL:url];
if([dc presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES])
{
NSLog(#"menu is presented");
}
When I run the program and click trigger buttonPressed, the NSLog message is printed, and an action sheet appears with two options. One is evernote, the other one is viewer.
However, when I click either option in the action sheet popup, nothing happens.
What am I missing? Do I need to implement a delegate method?
Please help. Thanks!
i've got the answer.
i must retain dc..
fool mistake :(
Related
I have a sandboxed Cocoa app. I noticed that when I call [[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:path] no Finder window opens the first time is called. Finder.app is brought to the foreground (menu bar changes to Finder), but otherwise nothing happens.
When I bring my app back to the front and again have it select a file in Finder, the Finder window opens with the file selected as expected. I tried this with #"" as second argument, same thing.
When a Finder window is open already, everything works as expected.
Has anybody else seen this problem? Workaround is to immediately call selectFile:... twice, but that doesn't seem right.
Edit: not related to sandboxing. Same issue without sandbox.
I think activateFileViewerSelectingURLs is better. It correctly selects multiple files in the finder.
I hit a problem in an iPhone app where it crashes, displaying the following message in the debugger console:
2012-08-31 12:31:24.628 test_app[1672:207] -[My_ViewController
tapDetected:]: unrecognized selector sent to instance 0x7621ef0
The strange thing is that "tapDetected" does not even exist anymore in my code for this class. It used to be a method, but it has been removed and replaced by a different one.
I noticed though that when I look at the .xib file, in the first responder, "tapDetected" still appears in the list.
But I don't know if this has anything to do with my problem or not, and I do not see any way to remove it.
Any idea or suggestion about this issue will be welcome.
Remove tapDetected: method from .xib from where it is calling.
Open your .xib file. Select the button in your .xib file which generated the error. Select Show Utilities=>Click on Connection Inspector=>Check the Sent Events list. Remove the connection to tapDetected: if exits.
This could be because the button in xib (which i am guessing gives the error when pressed) is still connected to the method..in ur xib file..just delete that connection from the connection inspector list for that button..
I want to add that when you deal with interface builder stuff and xib files, sometimes your app can also crash regardless of making sure you deleted something from your xib file.
I learnt that this was cause because the previous copy of the app on the simulator is somehow "caching" the xib contents.
The fix was to delete the instance of the app from the simulator or device, then re-run the app again.
hello everyone im trying to create this tweak that copies a file from one spot to another everytime a specific app opens. Would this be correct to use. im still really new to this, but trying, what command should be placed to have this run everytime the app opens.
- (BOOL)fileManager:(NSFileManager *)fileManager
shouldCopyItemAtPath:(NSString *)srcPath *path/to/where/file/is
toPath:(NSString *)dstPath *where/i/want/it/copied/to
If you want this to run every time the app opens then you can call it from application:didFinishLaunchingWithOptions: in your app delegate.
In my document based app I call prepareWithInvocationTarget and registerUndoWithTarget for [self undoManager]. However, in Edit menu, Undo & Redo are still blank. I can execute undo manually by calling [[self undoManager] undo] and it works.
Just to make sure, I created a new project, called in it prepareWithInvocationTarget and registerUndoWithTarget. Magic! Undo/Redo elements in Edit menu could be clicked now.
What could be a possible reason for this? I tried checking connections in interface builder but they are the same as in the new project I created. Any idea how to fix it?
Ok, I've got it worked out.
The issue was that I had a document based project and in my document delegate I callsed [self undoManager]. I was supposed to call it on the main window instead. I've chcanged it to [mProjectWindow undoManager] (because mProjectWindow points to the main window of the document) and now eveyrthing works fine.
This is pretty weird and I would very much appreciate all help =)
I have a document based app where it should be possible to perform some actions on the document file. To do so I'm saving the document every time the document actions are called. To do so I'm using the method:
saveDocumentWithDelegate:didSaveSelector:contextInfo:
The problem is, that when closing the document, reopening it from the recent files menu and then performing the action again I'm being presented with the dialog box saying that
This document’s file has been changed by another application since you opened or saved it.
However this is not the case when using the save menu item.
I've tried with different save methods:
saveToURL:ofType:forSaveOperation:error:
And even though this results in the behavior I'm looking for there is a side effect: The save menu item becomes deactivated after performing the action.
So my question is: How should I correctly perform save operations programmatically? I've looked through the docs but I haven't seen anything which looks like an obvious solution.
All help is appreciated. Thanks
I found solution for this problem in my case.
Problem was in options in overriding of configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error: method of NSPersistentDocument. Problem was solved when I delete string
[options setObject:[NSNumber numberWithBool:YES] forKey:NSSQLiteManualVacuumOption]
I used vacuum option for some reason. Don't know how but it caused problem with saving. When I refused this option the problem has disappeared.
To get it to work as you want, you can probably fix it by using the saveToURL:... method and then call -[NSWindow setDocumentEdited:] or -[NSDocument updateChangeCount:] which will stop the menu item from being disabled.
However, I'm not sure your overall approach is right. If you have a save menu item, I don't think you should be saving automatically unless you're using Lion’s auto-save feature (recommended) in which case you would call different methods.
And even if you did decide to stick with the auto-saving as you have it now, why wouldn’t you want the menu item to be disabled? It’s disabled because there are no changes to save.
Why are you auto-saving the file anyway?