Is there any way to save an image an default.png programmatically on the iphone? - iphone

I writing an app for the iphone and I would like to save an image from it as the default.png for the next invocation. Is this possible? It seems as if the sandbox doesn't allow you to overwrite anything in its local filesystem.

No, you can't. It used to be possible to make Default.png a symbolic link into your Documents folder, then to rewrite the location it pointed to, but functionality was removed in 3.0. You should file a bug with Apple explaining your needs.

No you cant, what you can do is save the image data to a file or using core data and then retrieve it for use.
So you can do something like
if(dataIsThere)
//use that data for image
else
use the default

Related

Best way to store images in iOS

I was wondering if anyone could suggest the best way for me to store images for my app.
I want to be able to provide an XML update functionality that will allow the user to update their app with a new set of images. I was wondering what the best way to do this was as i need to read and write to the store location. Is storing them in a sqlite database the best way or am i able to use the filesystem to do this without the chance of the iPhone deleting any of the downloaded images?
Thanks
You can write to the filesystem, every app in iOS is sandboxed and has access to his own documents folder.
I would suggest to write on filesystem and only save the urls on the database as that is more performant than saving blobs on a database.
Apple has a good write up about the iOS filesystem.
Alternatively you could implement a solution using SQLite, Apple mentions it in the: Large Data Objects (BLOBs) section here:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdPerformance.html#//apple_ref/doc/uid/TP40003468-SW5

Is there a maximum size to NSDocumentsDirectory? Are the contents accessible outside the app?

Is there a limit to the amount of data that we can put to the NSDocumentsDirectory? My application allows photo and video capturing and I am saving this data to the NSDocumentsDirectory. Can I keep on adding images and videos to the app then? Also, are these images and videos accessible outside the app? Can we delete them using iTunes? Help please!
You should start with reading apples programming guide for file system access.
And remember: Whenever something in the apple docs reads like a hint or a recommendation, it actually says "do it that way or we won't let your app into our store".

iPhone: Saving picture/data to "public" folder?

I want to implement a backup feature in the app I'm working on, that simply puts an image and some data in a folder that can be accessed through itunes or similar.
But is this possible, and what can be done?
Point of the feature is that if (for some reason) the image and data isn't sent to my server, the user will have the ability to extract it to a pc/mac, so that the image and data isn't lost.
Any help is appreciated.
Enabled iTunes file sharing in your app's settings and then write your file to the Documents folder in your app. This will then allow them to see the file through iTunes.

Where is the file of the recording located on the iPhone SpeakHere example?

It is as simple as that.
When you use the SpeakHere example it should create a file somewhere on the iPhone that contains the data from the recording.
Does anyone know how I can find this?
Thanks!
EDIT 1
To be clear, I want to do operations on the wav file within my application. I have some code that needs the URL of a wav file. What would that be in the SpeakHere example? (Keep in mind this is all within the same app).
EDIT 2
I appreciate the suggestion #sudo rm -rf, but I would really like to stick to the SpeakHere example as it serves my purpose well. Have you looked at the mRecordFile variable in AQRecorder.mm? Could that be it?
Well, I tried the app and it looks like it doesn't even save it to disk (it should be in the Documents directory); I'm not sure how it's holding it. Maybe in memory? Anyway, if I were you, I'd not use that sample code for recording audio. It's meant for iOS 2, and is quite outdated. Try visiting THIS question and read about how to use AVAudioRecorder.
Edit:
Found where it saves the audio file to recordedFile.caf. However, it's saving it to a temporary directory. So, to access it you need to use:
recordFilePath = (CFStringRef)[NSTemporaryDirectory() stringByAppendingPathComponent: #"recordedFile.caf"];
player->CreateQueueForFile(recordFilePath);
An App can only store data inside it's own sandbox. This means, it's stored inside the bundle of your example App and can't be read by any other App, except by the example App.

Saving custom image (non-JPEG) to iPhone Photos directory

I'm wondering if it's possible to save a non-JPEG file (e.g. PNG) to the iPhone Photos album. I'm trying to do this in order to save a lossless image. Currently, I'm saving to the application bundle's document folder, but I'd like to be able to save to the iPhone Photos album so the images may be viewed later (without explicitly copying them out of the bundle). The function UIImageWriteToSavedPhotosAlbum will not work because it writes a JPEG file.
Thanks
Apparently, you can use a workaround, I've found it right here on SO.