MainController.xib file required for every project? - ios

Is a MainController.xib file required for every iOS project? Reason I ask is because I have started to work on some programs, and I noticed that with some of the defaults there is no MainController.xib file generated.
If it is not generated by the template, does this mean that I have to create one myself using "Add File?"
I have a vague recollection of reading somewhere that MainController.xib generated the first view when the program loads but am not sure if this is correct?
Thank you.

It's not required. As far as I know, none of the templates in Xcode 4.2 and 4.3 create a MainController.xib.
Your app's Info.plist can contain the “Main nib file base name” key. The raw key is NSMainNibFile, and it also shows up on the app's Summary screen as the “Main Interface” combo box.
If this key has the value MainController, then you need to have a nib named MainController. The app will automatically load this when it is launched. You can set the value of the key to something else if you want to name your main nib something else. (I usually name mine MainInterface.)
If you don't include this key in your Info.plist, then the app won't automatically load a nib when it is launched.

That looks like a default name generated by XCode. Depending on the project template, whatever the the .xib file is named, you get a controller to go with it.

Related

Create a plist outside Xcode?

In our app we have lots of photos that we need to read while using the app, we have to also orgenize them into groups/categories.
this option is to make a plist with their names, and just put them into the app and read the plist.
create folders inside the app, order them inside, and read the specific folder.
Option 2 took me days and I couldn't even make it work reliably, and it also seems not the right way to work for some reason.
Option 1, the problem is that if you have 100 files you have to edit your plist every time again for a new file you add.
Is there a way to make option 1 outside of xcode so I can put all files in a folder on my mac, get their plist, and put this plist inside Xcode ?
What's the right way to achieve this ?
plist is just a simple XML file. You can create the plist file and add to xcode as any normal file to the bundle and read it.
macOS comes with two command-line tools for manipulating plists:
/usr/bin/plutil can convert a plist between formats. You might like this because you could write your photo catalog in JSON using whatever tools you like, then convert it to a plist. Of course, then you could just use JSON directly in your app…
/usr/libexec/PlistBuddy (note that /usr/libexec is not normally in one's PATH) can modify a plist in place, adding, removing, or changing entries.
Both of these tools have man pages (man plutil, man PlistBuddy) and substantial built-in help (plutil -h, /usr/libexec/PlistBuddy -h).
First, you're making a false assumption. There is no need to use a plist file here. An ordinary text file listing the names will do just fine, and you can just make up your own format to dictate groups and suchlike. And that sort of file is trivially easy to maintain.
Second, your rather confused claim that "Option 2 took me days and I couldn't even make it work reliably, and it also seems not the right way to work for some reason" is just a cop-out. Folder references are not a difficult thing to use (you can configure them in the Finder, which is as simple as you can get), they do work just fine, and they are a perfectly reasonable solution here.

Updating plist file via code

I have created a plist file in the bundle, and I'm trying update the user's information into the plist. I know that I should copy the plist file from the bundle to the document directory, and edit it from there, but I still have a couple questions:
When I copy the plist file to the document directory, is it permanent? I mean, if I close the program and open it again, I can simply edit the plist file in the document directory, right?
If so, does it mean that I should only execute the code that copies the plist file to the document directory once the app is launched for the first time?
/main question/ Since I want a blank plist file for the user to update their data with, should I just simply create a plist file on the first launch? It'll be a lot easier without the copying around bundles and stuff.
I mean, what is the point of creating a plist file in the bundle in the first place? We will copying it into the document directory anyway, so why not just create one in code?
Yes. Writing a file is permanent, as long as you obviously don't delete/move the file somewhere else.
That is a valid option
Yes. If you need a blank file, you don't need it from the bundle. A better idea would be to create it when you need it (when there is something to write). Usually file creations are managed like so
Check if file exists
If not, create it.
Use the file.
If you need a template file (with already some stuff written in it), then a copy from the bundle is more appropriate. But even then, a lot of developers will like to do everything from code, it's not that heavy of a task, and it forces you to create/prepare the right objects and methods from the get-go.
Like Rooe N said, the NSUserDefaults IS a property list, so if you're talking about very simple data, say, like a username and a last-time-I-logged-In-date, you could store it there.
Note that NSUserDefaults are loaded all the way, every time you load the app, so you don't wanna use it as a database. But since you're going for .plist, I'll assume you've already ruled DBs out.
I'm not completely sure what you are trying to achieve, but you should think of plist as a place for global Constants not something that should be updated on runtime.
Maybe you should look at this:
NSUserDefaults

Configuring iOS application with external config file

I need to be able to configure my app via configuration file.
How do I go about it?
The first thing that comes to my mind is having a .plist file that stores values and to have an singleton class and ask that class for values whenever I create element in question in code.
Or is there any better way to do this?
Depends on the amount of content and size of the configuration file.
If it's a couple of key-value values, I would just go with NSUserDefaults.
If it's a bit more, arrays or more advanced data models, I would go with a .plist. But remember to move the default .plist into the /Documents folder, you are not allowed to edit files in the app bundle.

mergExt - localizing app with mergSettings on iOS

I'm localizing my iOS app and having difficulty translating strings in the mergSettings extension for LiveCode. I setup a new folder - ja.lproj. Then, I made a new file called "Localizable.strings" inside of that folder. I then created "key" = "value"; pairs. I loaded the app and the strings were not translated.
Any ideas on what to try next? Monte?
The settings bundle has it's own localized resources folders so ja.lproj needs to be inside Settings.bundle. Also I'm assuming when you loaded the app the locale was set to ja?
EDIT
The file should be named Root.strings

Disable file preview for a custom file type in iOS

I have associated a file type with my iOS app, so I can open files of that type in the app, e.g. from an email. Opening files works, but simply tapping on an attachment in an email opens the quick view screen, which comes up blank. The file format is a zip file with a custom extension, which I believe is unique.
What can I do to disable the quick view for my file type?
I hope you came up with a solution since :)
For people who may be searching for a solution too, have a look on the protocol(s) you custom type inherits from (array key UTTypeConformsTo, name "Conforms to UTIs")
In my case, my custom type is a zip archive with a custom extension (as you) and I put "public.data" and "public.archive".
The "public.archive" was responsible for the OS to display the content of my custom zip in Files app, or having the Quick look in Mail app.
The solution was to inherit only from "public.data".

Resources