Storing Huge Amount of Files in the Application Bundle - iphone

Um, I working on a dictionary app and currently trying to add narration for each article. I have about 97000 AAC-files. They are tiny - about 3-5 kilobytes each, but there are so many of them! I don't need SQL DB for access management because filenames are identical to the primary keys, so given the key I will be able to pick a proper sound file from disk and play it (I expect so).
The thing I worry about are issues related to huge number of files. I don't really want to mess up with CoreData.
Will there be any problems if I just add all these files to the application bundle? Will Xcode be angry at me? Will iOS be OK with that?
If not what should I use then? How to handle huge (~100'000) number of files properly?

There is no restriction on the number of files that can be added to your application bundle.
It would be better for you if you can put the files on a folder(say audio) in the app bundle.

Related

iphone embedding images in the executable file

When releasing to the application store someone wrote in an offhand comment that you need to avoid embedding your images into the executable.
How do you do that?
I've seen code in various books that suggests encoding images as C byte array constants in the source code, and I can say that that's definitely a bad idea for reasons ranging from inefficient pixel formats to unsalvageable memory. That would qualify as "in the executable file" in a way that bundle resources don't, since bundle resources are packaged alongside the executable rather than within it.
I am not sure if I get you correctly, but maybe he meant accidentally adding image files to the Compile Sources category in your build target? This usually does not happen with images, but i have seen it happening with js files.
Perhaps they meant that you should only include images in the bundle that are essential.
The bundle is essentially read-only so you cannot remove an image from the device that is in the bundle. Therefore placing lots of example images that you expect a user to remove/not want is not a good idea because when the user deletes the images from inside your app no space on the device will be reclaimed.
Of course it is fine to place images in the bundle just make sure that they are required and are not taking up unnecessary space that the user cannot reclaim.

Xcode Project Size problem- 72 text files

I am new to iphone sdk and creating my first application so please be nice when answering my questions.
I have following questions
Q-1. I have created a simple iphone application (not a game app, no OPenGL). My program is running fine but total xcode project size is 9 mb. I found that my xcode project size is less than 2 mb without "class" and "build" folder.
Do we upload files of "build" and "class" folder when we submit our application?
I have checked that most of iphone applications are less than 2 mb in size so I think build folder is just for me to test the application.
Can someone give me the list of all files or folders (just extension) that we need to upload in order to submit an iphone application.
Q-2. there are around 72 text files (each is 2 KB in size) in my program. Program open a text file according the selected criteria. I have all 72 text files in resource folder. I am not using SQLite as I think it is not too much data and text files are small in size.
Can apple reject my application just because there 72 text files? Is it a common approach to use multiple text files instead of SQLite?
Q-3. Do I need to add zip and unzip my text files instead of opening them directly?
Q-4. some of my text files has following five words
"sex" "sexy" "kinky" "filthy" "dirty"
For example "You are so kinky" , "I love sex" etc.
Do I need to remove these words from my files? Will they be considered vulgar? Will my application be rejected because of these five words?
I have seen some iphone applications on apple's website which shows sex positions and use words like sex,sexy,kinky so I think it should not be a problem.
Do I need to add something like "mature content. Must be 18 years old" just because I am using these five words. I think these are pretty common words that are frequently used by young people.
Many of these questions can be answered more completely by Apple's help docs in the iOS developer center and iOS Provisioning Portal (https://developer.apple.com/devcenter/ios/index.action and https://developer.apple.com/ios/manage/distribution/index.action - you need to be logged in to view these links)
However, here are some quick answers:
1) The build and classes folder hold files during development. The build folder holds the binaries that are created every time you click 'Build' in Xcode, if you build for different targets, there will be multiple copies of your binary in this folder. It also contains various debugging and symbol files used by Xcode.
The classes folder contains all of the implementation (.m) and header files (.h) that you have in your project. This folder corresponds to the 'Classes' group in the file organizer when you open your project in Xcode.
When you submit an application to Apple, all you submit is the compiled binary (found in the appropriate folder in your 'build' folder). It is normal for your project folder to be many times bigger than the final binary you submit. For more info on the submission process, refer to the second link I posted above.
2) If you're persisting a lot of data, I would recommend using the built in SQLite database. It's very easy to use (Google will help you with this), and quite fast. Apple probably won't reject your app for storing a lot of data in flat text files, but you have no reason to. SQLite databases are much cleaner and easier to maintain than 72 flat files.
3) No. But you should still use SQLite, especially if you're saving enough data to these text files that they need to be compressed. Reading and parsing large text files can be much slower and more cumbersome than reading the same data from a database (databases are made to handle data storage like this).
4) Again, Apple probably won't reject you for this (of course, nobody actually knows why they reject apps, so it's always a bit of a crap shoot). When you submit your app, you can choose the rating level for it (sort of like game ratings, or movie ratings) so when people download it they are aware of the level of maturity of the content. One of the ratings is 17+, which you can use if you need. I believe Apple has a document outlining it's rating system in one of the links I posted above (or it's somewhere, it does exist).
First of all you don't need to upload build folder to upload but classes will be uploaded. you have to follow a process for uploading.
No problem at all you can upload even 1000 files, 72 is very small amount. but be careful that if you project is very heavy then it app will be crashed.
No need to zip the files.
you may use all of these words you may even use pornographic contents but they should not be copy righted of any body else. You don't need to remove them, when you will be uploading your application there will be an option "Application include adult contents" you just have to check that option.

Product idea/approach : Folder based disk organization

Sweet..I bought myself a 1TB portable harddrives this week. Don't you just love how much data you could store on one of these disks? The fact that I could store my bluray rips on to my portable harddisk and that my lg lcd tv can do HD rips right from the drive - that's amazing practicality right there! However, life it seems, is never so simple. I have 100s of movies unorganized in one huge folder, which is exactly what I needed to annoy myself while browsing the same on my tv to play a single movie. That got me thinking...
What if I had an automated way to organize movies into folders such that my folder-browsing-on-a-lcd-tv-or-a-comp would make my life a little easy?
I started thinking about this... I browsed a little in this context and I realized that if only I could "tag my movies somehow and create folders on-the-fly based on tags using hardlinks", I would have addressed my problem. I googled a bit to find software that works in the above fashion, only to find none.
A few more days of serious thought (as you know by now.. I think a lot.. and I guess this question is starting to sound like a blog rant/post of sorts...), in the interest of humanity, I thought I should come up with a generic way to address this: What if someone wanted to organize photos... organize music.. organize software?!
Turned my grey cells off for a while and here is an approach I came up with to solving my what-if scenario.
Tag / Group tag individual files (rely on a slick GUI to do it fast and do it good) - Adobe Flex/Eclipse RCP to do this?
Create hardlinks to each of the tagged files.
The first point is self-explanatory. The second (coz I am talking windows here), refers to making use of mklink.exe.
Consider a scenario where I have 2 movie files: I have a movie file "Transformers.avi" tagged as "english, action, bluray, sci-fi, imdb-top-50, must-watch-with-kids" and another movie file "The Specialist.avi" tagged as "english, bluray, thriller, adult". Here are a few of the possible locations I want to see my Transformers to be found:
[root directory]->all-tags->english
[root directory]->all-tags->bluray
[root directory]->all-tags->english->all-tags->bluray
[root directory]->all-tags->bluray->all-tags->action
[root direcotry]->all-tags->english->all-tags->action->bluray->all-tags->imdb-top-50
Given that windows has a limit of 1024 hardlinks to a single file, I probably would be allowed 7 unique tags per file. Each sub-folder will have an "all-tags" folder. Having it named "all-tags" makes it more accessible when order by name.
I believe this approach when automated to let you configure tags you want and where the hardlinks are created for you, helps you organize stuff effectively.
I don't know if there are better things out there. I would like your inputs on this approach and other possible ideas. I would like to gather inputs here and release something to sourceforge for everyone to use in a couple of weeks. I am sure, I can count on your positive response as always.
I believe hardlinks are not a good approach. Reason? A standalone player won't play them, and I wouldn't like a program who's made for tagging to tell me to stop making so many tags because of a Windows limitation on hardlinks (remembering each tag will increment the number of links exponentially).
Plus, "help" is not a good tag.
And I've had an idea once that I'm still planning to make some day to sort my own files - put the files in a big storage each below a GUID foldername (filename untouched) and store metadata in a sqlite database to be used by a smart file browser.
I was considering doing something similar to this with music for detecting duplicate songs and auto-organize funcationality.
For your application, I wouldn't recommend using any shell programs through Java. Exception handling becomes difficult, and your application becomes bound by the shell interface and implementation (i.e. windows versions or installations affect your application behavior).
I would use a database with a few tables: Files, Tags, and an association table.
The Files table would list the physical location of each file, the filename, and a unique identifier. This way, you can maintain information about each file without having to modify it for every tag association.
The Tags table would list each tag, and any metadata you want to store for each tag.
A third table, maybe 'FileTags' would store the assocation between tags and files. When adding tags to the stack, you would add a statement to the WHERE clause, and the list of files with all of the tags would be returned. This structure would also allow open your codebase up to other designs, such as include/exclude (autocomplete with X buttons), or possibly search.
If implemented in Java, your app would be platform independent, and would allow a very large number of tags and files. You can then use the system default application for opening the media file, and the user can make the selection in their native OS.
Reiser4?
...
(I mean nevermind Hans, but the tech...)
[disclaimer: Not a hacker. I know nothing of programming/coding, never mind filesystems & databases. I can barely code decent HTML even, if at all. Hey y'all! :D]
[footnote: does plain HTML5 work here? Too lazy to close my tags hehe :p]

Importing huge music files into database

We have very huge music files in mp3 formats (very huge more than 1,000,000) and would like to import all these songs into the DB of an application we are developing. Is there any easy method to import such huge files at once. Kindly let me know
Why not just use a filesystem for them - that's what file systems are designed for? Index the filenames in a normalised DB.
Yes, there is
Take a look at how has Apple solved that problem. Go to the iTunes_control folder on the iPod. You'll see that there's a Music sub folder with dozens of folders named f00, f01, ... f50 (50 is arbitrarily big number). Every file has been renamed to a filename that looks like a hash value.
Use the file system to store the files. In the database store the path to the file on the file system together with the mp3 metadata information (artist, name, album, composer, etc) and provide search capabilities over it.
You don't want to store music into the database. Store some kind of URLs to music into the database, with all the metadata you want to keep, and store music into folders on various servers. I am author of radio automation software that used this scheme and we never looked back at our decision.
Main reason for that is that you don't want anyone to be dependent on some database API to extract the music.

Managing resources and keeping them out of version control

My iPhone app will have a map with about 10 points on it. It will play sound files based on the proximity to those points.
What's the best way of managing these resources?
Coordinates and accompanying sound file could be stored in a plist, as an array of dicts with latitude, longitude and file name. Then the sound files could be stored separately.
The plist and sound files should not be version controlled.
How much, and what, should happen compile-time, and run-time? How do I manage this?
The end result should be an app binary with the sound files embedded and the records stored in core data. Doing stuff on first launch of app is also OK.
I think my question could be rephrased to: how do I manage resources programatically, at build time?
Add the sounds folder as a 'folder reference'. Then any files you add to that folder will be included in your bundle. Right click on your project->Add Existing Files then choose 'Create Folder References'