Can I turn off saving in a Document Based app? (Swift for OSX) - xcode

I'm trying to make an extremely simple note-taking app for OSX: one that can have multiple windows open and where I can quickly write down something. I don't want to store anything anywhere.
Most importantly: it should not nag about saving on quitting the app.
I'm nearly there, but I am stuck at turning off saving.
Any ideas if this is possible for a Document Based swift-app?
(using Swift and Xcode, complete NOOB at this)

There are different types of applications. You can specify this when you start a new project.
Disable "create document-based application" when you start a new project and it won't nag you about saving anything.

Related

How can I add files to the iOS simulator in a CI environment?

I would like to include a UI test in my project that exercises its interaction with UIDocumentPickerViewController. The test will need to run on a CI machine, which needs to be able to wipe the simulator before each build, and operate without a human driving the GUI (either on the machine or the simulator).
There are a number of answered questions around how to add files to the iOS simulator, but they seem to all require manual interaction with the simulator UI. What I've tried so far:
Using xcrun simctl openurl file:///path/to/my%20file.pdf, but that just presents a sheet in the files app that would need manual intervention to actually save to the simulator.
Using xcrun simctl addmedia, but the media need to be images or videos and they end up in PHPickerViewController and not UIDocumentPickerViewController.
Using the openurl command above before the test kicks off and then adding a button in my app to open the shareddocuments:// URL to present the Files app, and using the UI test runner to click the "On My Phone" and "Save" buttons. This looks promising but also promises to be flaky.
What I haven't tried yet:
Set up a sockpuppet iCloud account and log the simulator into that account on every test run in order to use iCloud Drive. This seems like yet another credential to manage that will randomly break when it needs to agree to some new terms and conditions.
Replace my test app with a document-based app and figure out how to save a file from the bundle to its file storage without manual interaction. I'd love a guide on how to do this but it feels like I could easily spend a week getting up to speed on document-based apps to get it working.
The code I'm testing is a framework, so the app under test is free to have features that would make no sense to an actual user and is also free to do non-app-store-safe things. But it seems like other developers might appreciate a more general solution if you have one.

UI Automation for AppleTV system using XCode

Is UI automation available for the main menu of the Apple TV and not a specific application? I already setup the whole UI testing thing using XCode and tried using the remote control but it is only available for the application that was defined using XCUIApplication.
So is it possible to control the whole system rather than a specific application? I was thinking of something similar to pyatv but using XCode since I might be able to get more information concerning the current focused apps and so on.
There is an API XCUIApplication(bundleIdentifier: ) to interact with not-AUT apps. You need to substitute the right identifier for this Springboard-like interface. Maybe it is a Headboard, but I'm not sure.
Bundle identifiers of tvOS apps https://github.com/rzakhar/XCTApps/blob/master/Sources/XCTApps/tvOS.swift

Cocoa app, create new instance of app with file new?

I've created a mac application. Runs great, all is good. However, I want to be able to have multiple instance of the same app. So, all my app has is one window and a view controller. I would like to allow the user to go to File -> new and instantiate a new fresh instance of the already opened window, so the user can have as many open at the same time and have each handle its own options.
I hope this makes sense. I am new to Mac Development. I am not sure how to go about this. Any pointers?
However, I want to be able to have multiple instance of the same app.
Don't. This is not an idiomatic behavior for macOS applications; there should only be one instance of an application open at a time.
If you want to allow the user to open multiple windows (like you can in TextEdit, for instance), what you are describing is typically known as a document-based application. Read Apple's documentation for details on how to create one, and what it will do for you.

How to make an ipad app impossible to close

I am programming an app for an experiment by the University of Queensland Psych Department. The app needs to be impossible to exit, or at least it would be preferable if it were impossible to exit. This is not a virus- it is for an experiment with the Grute Eylandt Aborigines. Anyways, do any of you guys have any idea how to set the app to be impossible to exit, or even better, to set it so that you have to enter a password to exit it? Furthermore, on a separate subject, do you guys have any idea how I can save the information in the app to the iPhone? This app will not go through the App Store so it does not need to follow App Store rules. Therefore, if there was a way to save "Button (whatever button it is) pushed at (time and date)" to the notes section of the iPhone every time a button was pushed in the app, and/or to save audio recorded using the AudioToolbox framework to the actual iPod library, that would be fantastic. Otherwise I would have to make some sort of db or plist file to save everything with if-then statements, I think. Thank you!
Check-out iOS 6 Accessibility feature:
It allows a parent, teacher, or administrator to limit an iOS device
to one app by disabling the Home button, as well as restrict touch
input on certain areas of the screen
Put the device in a "kiosk" case so keep the home button from being pressed. For storing the data to the device, if it is a small amount of data, use NSUserDefaults, if this will be a large amount of data, I would lean more toward Core Data
Easiest solution on the market -- MOKIMOBILITY has developed software that allows you to lock the home button. It is Mobile Device Management software with a full range of security features. It essentially locks down your iPad so the user is only able to use what you what them to use. It is called +MDM www.mokimobility.com The software can be managed mobile-y from a central interface. Slick software.

How to implement "Open With" contextual menu in OS X

Apps in OS X that can open files to launch their respective applications often let the user choose the app that'll open the file. An example is the Finder.
I am still unclear about what's the best solution to implement this. The challenges are performance and showing the app's icon.
First, to get the list of apps, I found only LSCopyApplicationURLsForURL().
The major difficulty for me now is to get the app icons. All I have is the URLs (paths) to the apps. The only way I know of to get the icons would be to create a CFBundle object and then read the app's plist to get the icon data. But that appears to invole lots of disk access, and I could imagine it'll be quite inefficient if the app is located on a remote file server.
I believe that there's also a cached database about the apps, which includes icons and display names (without extension), and such. But where is the API for that?
Note: The app is Carbon based, but I can make use of Cocoa (NS...) functions if necessary. Also, Support for 10.5, even 10.4, would be appreciated.
Alright. I solved it eventually.
I now use the Carbon function GetIconRefFromFileInfo(), which still works in Lion, though it's marked deprecated/obsolete.
I had also tried to use QLThumbnailImageCreate(), but that didn't get me any results, oddly. No idea what I did wrong.
For Cocoa apps, [[NSWorkspace sharedWorkspace] iconForFile:path] can be used (thanks to C. Grunenberg of DevonTechnologies for this tip, where it's used with EasyFind).

Resources