I am new to programming mac apps in Objective-C and need help with this. When I control click and drag to first responder from a button it brings up a box from which you can select some predefined functions that run when the button is clicked. On of the functions says newDocument. I was wondering if this means that it creates a new document (file) and if so how to actually make it create the file. I tried selecting newDocument but when I ran the app it said this: 2016-03-16 15:39:57.889 Test[26619:4382721] The (null) type doesn't map to any NSDocumentClass. My button is simply named create file and has no code attached to it, only the predefined function.
The method you are seeing, newDocument, is part of the Document Architecture. If you wish to use it you need to study the documentation, the particular function newDocument creates a "document" within your app along with an associated "window" rather than a "file" per se.
It sounds like you really need to read the Cocoa Event Handling Guide to learn how to handle a mouse event, and the File System Programming Guide to learn how to read & write files.
HTH
Related
I wrote a Pharo program that generates my daily task non-stop.
The program itself works fine, however I always need to instantiate my object in the playground to run it. Is there some other way of doing it automatically without having to create an object and send a message to it?
Yes, you can. Save the image after you have instantiated your application and closed everything else. Then just start pharo from the image and you will have your application started.
If you want to do it more production wise you could use pharo-launcher.
For more detailed information you could squeak wiki which you can adjust to Pharo.
I would do one of three thing here:
Add an item to the World menu, so you can bring up the menu and select your task. See a Stackoverflow Answer on that same topic.
You could write some triggering code in a .st file on your file system, then use StartupPreferencesLoader to load it on startup.
Create a window morph with a button that, once pressed, runs your code. Open the window, quit and save image changes. Never close the window.
I've already got the useful tip of how to play an external audio file.
And now I'm struggling of how to use it upon reaching a certain page.
I've managed to find that I have to add the stuff below to obtain a list of events I can use:
Public WithEvents App As Word.Application
And I got a plenty of the events:
App events
But no one from them seems corresponding to what I need.
1)Find out a certain event I can use, to track any action which might change currently viewed page(mouse scroll, arrows, page up/down, mouse move with selection, or any of others..) and then paste a checking function into.
2)The checking function supposed to obtain number of current page within the document(or it's equivalent) and if we are at a certain page play corresponding sound.
There are 2 main problems I've struggled with, but got no good idea.
I also aware that we can use ActiveX object and insert an audio file into the document, it allows to even not keep the file somewhere, but embeed it into the doc.
However here I even have no idea of how to trigger playing of the file through VBA.
But if somebody can advise about it would be perfect because it even more handy, in terms of maintenance(no need to keep external audio files).
Any help is appreciated.
If you know that it's impossible in general, please also let me know, so I can close the topic.
I'm writing a very simple Mac OS app to parse a text only video EDL (edit decision list) and pull out locators (or 'markers' if you're familiar with Apple's FCP nomenclature) and add them to a new NSMutableArray to be displayed in an NSTableView.
All of this works perfectly, resulting in something similar to the following image for my test EDL:
My ultimate goal is to further process this list and reduce it to only those markers which contain a video effect (VFX) name. Those are the RED markers in my sample. I want to be able to open a very simple pop-up window asking which color represents the VFX (again, RED in this case) so I can simply iterate thru the array and print those locators only.
I've created a new window and window controller to open the following window:
This works great, and I can use an NSLog within my new window controller class to display my typed responses.
The question then is: how do I pass my typed response back to my calling class, and then execute a new method to use this response for further processing of my array?
As it is now, when I hit the 'OK' button, it executes a method (in my new window controller class) which assigns the text in my NSTextField to a new NSString. But how can I then ALSO pass that variable back AND execute another method in the original calling class which holds my EDL array?
I'm sorry for the newbie question, and I'm not asking somebody to actually write code for me, but I don't even know what to look for in the manuals to study up on this. I'm a video editor first and a coder only as a hobby, so go easy on me please.
Thank you, btw, to Phillip Mills for helping me get as far as I have with the TableView.
So I am making an xcode application for OS X, and so far things have gone well. However, right now I am at a roadblock. My app is mostly one window, and I need that window to be created multiple times, in the way that apps like Safari, TextEdit, and all those ones have the File>New function. I am new at Xcode, and I was wondering if there was an easy way (hopefully 3-4 lines of code) to do this. If someone could explain that to me that would be great.
Thanks!
Start a new OS X project and choose "Create Document Based Application" . This will create a NSDocument subclass.
If you want to use Core Data , choose that also. This will create a NSPersistentDocument subclass.
This will give you the basis of your application with all the functionality you ask for.
Have a look at Document Based App Programming guide and NSPersistentDocument Class Reference
Whatever you do, dont try to bake your own. There lies madness.
The project template sets up the info.plist correctly to make this work.
Whatever I tell you, it won't involve only "3-4 lines of code," unfortunately.
If you're working from a non-document-based application, you'll want to factor out the code that creates your one window. If you're not using a window controller in concert with your window, you should implement one. Then you can implement an action that will create a new instance of your window controller, and so a new window. Of course, you'll need to add more infrastructure if you're interested in saving information associated with a window to a file.
Which leads me to your other option, which is to create a document-based application. The big advantage here is that, if you're interested in saving the window contents to a file, the infrastructure for doing so is provided. This involves starting over to some extent, but since you've already got the guts of your application working, you'd simply transfer those guts to the document subclass that is provided for you. You'd also need to provide to your project meta information describing the kind of document it is, including the file extension describing it.
Best wishes to you in your endeavors.
Can any one tell me about how to lanch a self-made application using the "openwith" feature of a mouse click event?
Your question is not very clear, but I understand it as "How do I tell the Finder that my application knows handle certain file types?". Once the Finder knows the link, it will suggest your application in the Open With submenu that appears when you ctrl/right-click on a file.
Have a look at the Apple documentation. Basically, you have to declare all the supported file types in Info.plist (or what you called it). The system is based on Universal Type Identifiers.