Is it possible to programmatically create a symbolic link on an iPhone? - iphone

I need to create a symbolic link on iPhone devices programatically in order to avoid a lot of slow file copying. Is this possible to do and if so, how?

It's technically possible, via the NSFileManager class. Grab the singleton instance and then use any of the calls listed under 'Linking an Item' or 'Symbolic-Link Operations' (createSymbolicLinkAtPath:withDestinationPath:error: looks like a good candidate).
Using a link rather than a direct file was a method briefly used by developers to update their Default.png programmatically, but that specific use has been outlawed by Apple. Besides that I'm afraid I have to plead ignorance on any SDK usage restrictions.

Related

How Programatically Change Spaces Sequence?

In the Picture above Mission Control is Launched, and we can see the Space Sequence:
[Mesa 1, Safari, Xcode, Discord, Mesa 2]
How can is possible change this sequence using Swift or Objective-C?
Depends on whether you want to use private API. There are a few github projects that support that functionality.
https://github.com/JulianEberius/qsx/blob/master/src/objc/CGSPrivate.h#L197-L198
https://github.com/lwouis/alt-tab-macos/issues/14
https://github.com/koekeishiya/yabai
This one even says it can do it without private API:
https://github.com/bigbearlabs/SpaceSwitcher
EDIT: as for the last one, I initially misunderstood your question that you want to switch to a different space which is not the actual question (my bad, this is how I found the question). Anyway, the aspect of the answer about using private API still holds. Though you probably will have to dig deep to find how...
For there to be a way to do that, Mission Control would have to have a publicly exposed API. I don't believe that it does and there is no way to accomplish what you are trying to do. You could send a feedback request to Apple and ask them to add that functionality.

Embed/Read Command Line Tool in a Cocoa App (Swift 3)

I'm new here, so please be kind - I am open for tips and corrections ;)
Actually I'm trying to write an OS for a Sportsmachine. It basically contains a Joystick (JoyWarrior A8) input via USB. After some time I am now able to read the axes of the Controller using XCode, a Swift Command Line Tool with OpenGL and GLFW. The axes position is put out into the console.
What I would like to do now is to use this output in a Cocoa App to write the UI.
My questions to you are:
Is there a way to integrate and read a Command Line Tool within a Cocoa Application?
Or is there a better way to directly integrate the input into my Cocoa App?
Thank you in advance! Please let me know if something isn't explained well enough or if you need some code snippet!
As a rule-of-thumb, if you ever find yourself wondering whether Apple has an off-the-shelf solution for a feature you're trying to implement, ask yourself if the feature would be of use to a significant number of other developers. If you think that it would, you should do some googling, because there's a good chance that you're right, and that Apple will already have a library/framework that does what you need. It's fair to say that interacting with a game controller is just such a feature, and, true to form Apple, provides API to save you from having to re-invent the wheel (or use third-party wheels) - here's the guide.

Name of special alert view iphone

I have been looking for the name of this UI element for a while now, but I cant come up with anything. What is the name of the round rect with 'Reloading Data' in it? I thought that I remembered using a view like this a while back, and there was some open source library that made its use much easier.
Screen shot of cydia.
The Apple API is private and cannot be used in AppStore apps. I and many others use MBProgressHUD: http://cocoadev.com/wiki/MBProgressHUD.
It's MBProgressHUD.
You will get more opensource controls on this link.
Why don't you just use a UIActivityIndicator? It essentially provides the same utility without the need to implement 3rd party code? Do you really need any custom behavior the class does not already provide? The simpler the better you know..? ;)

Localization issue in iphone

I need to make an application in which the user can toggle between two languages on triggering a click event on a button.
The problem here is that I have seen examples in which, if we want to load our localized nib file, then we need to change the language from the settings options and we can get the proper nib file loaded according to language selected.
I want to do this within my application, meaning I don't want to go to the settings menu and change the language and then reload the application.
I just want the above effect within my application (that is, through a button click event the app should be able to toggle between two languages).
Is it possible, and does Apple allow it?
Nobody here can tell you whether Apple will allow it, but if your app is well designed and there's a good reason for this departure from the usual way of doing things, you've probably got a good shot.
There's nothing to prevent you from loading a nib file localized for a different region. I'd probably avoid trying to use Apple's automatic mechanism, though. Just name your nib files using some pattern and load the appropriate one.
If you want your life to easy, you will take advantage of the Localization built into the operating system. Otherwise, you will have write your own methods to load localized strings or nib files.
There is no reason for Apple to reject an app that shows localized text based on an in-app setting. I work to help developers localize apps and, although I don't suggest this approach, they have done it and I've never heard of a rejection from Apple.
What you won't be able to do is use Apple's built-in tools, which rely on the system settings to determine a user's language and push the text from a Localizable.strings file. But it honestly won't take you too long to implement a similar system yourself using functions akin to gettext.
You essentially need to implement the same basic logic as any localization system:
1) Surround your in-app texts in a function that will display the proper language based on the user's chosen settings
2) Export your source texts (probably English into file
3) Translate the English strings into each language in a separate file
The function you write can follow the lines of gettext, which has examples in many programming languages. If the settings is "French" grab the equivalent string from the French file. If the setting is English, just print the English.
You won't be able to use Apple's tools, but you CAN do it on your own and Apple won't really care as far as I know. However, if you choose to localize into an Apple-supported language, follow this app localization tutorial for iOS using the standard Localizable.strings method.

Common, reusable iPhone-App configuration screen

I'm writing code that will allow my iphone-app to have a "configuration page".
A grouped, scrolling, UITableView... with cells that contain the needed textFields, switches, sliders, etc.
It is an ENOURMOUS amount of code. Is there an easier way?
Is there a way I could create a simple text-file, contain all my desired design choices and have my (reusable) code build the TableView for me?
Or... can I just do the whole thing quicker/easier in Interface Builder instead of code?
Basically there are two approaches here :
you rely on what Apple gives you and implement a Bundle Settings (basically a dictionary that describes how the settings screen should look like), and then , your settings will be in the "Settings" application of the iPhone.
The drawback here is that what apple provides is quite limited and you won't be able to implement some of the most complicated settings you can see in "standard" (pre-installed) apple application settings.
That's why many developers are switching to "inapp" settings thanks to open source FWK or they reimplement everythingh from scratch but it can be a lot of code as you said.
You reimplement your own UIViewController for settings or you rely on some framework that will provide you the UIViewController to extend from and ease your implementation.
There are 2 good frameworks for that (Jesse cited one of them, but there's another one )
InAppSettings ( http://inscopeapps.com/blog/inappsettings-10/ )
InAppSettingsKit ( http://inappsettingskit.com/ )
A comparison of the two framework can be found here : http://inscopeapps.com/blog/inappsettings-vs-inappsettingskit/
(ok that's from one of the two authors but at least this gives an idea ;)
If you can live with the limitations of the standard application preferences in iPhone, you can actually create this using a settings bundle which only needs a plist and optionally a localized strings file.
You can check out Apple documentations for this:
http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ApplicationSettings/ApplicationSettings.html
Claus
If you're looking for a ready made and reusable solution, you can check
http://www.inappsettingskit.com/
It's open source too, so it's useful as a base.
I never found an easy and efficient way to build complicated table view by using Interface Builder, so I think programming the settings view is more preferable.
If you're talking about using a text file or plist, you may want to mimic the Settings Bundle design of Settings app.
Load the plist data upon the app launch.
I've built something like what you're looking for. Going off Claus's answer as well, it basically just duplicates the interface of the Settings application using the same settings.plist file as the settings app. The only difference is that it's a view controller that you can put inside the app. There's a surprisingly small amount of coding involved, it was just a lot of looking at the settings app to see exactly how things were laid out.