How to save ALAssetsLibrary to usersDefault when i close my app? - iphone

When i save images in ALAssetsLibrary, it's ok to show them in my table, but when i close my app from multitasking bar - records is cleared. How to save them and stay load in my table when i run my app again???
I found this Saving ALAsset URL in NSUserDefaults

I think you want to save resources so that you can use them later. If it does, you can save the path of resource to your user defaults or core data, and store them into "Photo Album". When you need it, just use the path in string as the resource path to get it.
Take a look at ALAssetsLibrary+CustomPhotoAlbum, maybe you'll like it. ;)

Related

How to save image image with current location and some infos in FLutter

I want to save image taken in app with some information as current location(latitude, longtitude),around places(restaurant or something nearest place) ,some variables .this photo wil be shown in application in other page.At the moment i am saving image with rename file and get all infos from file name.Have any other method to save infos with image
AT the moment I am saving image as
/data/user/0/com.example.tflite_image_classification/cache/latidude#longtitude#aroundPlace.jpg
Can anyone have other stategy for save share please
If you are using the google map package, there is a method exists in the instance which is called takeSnapShot.
ex: mapController.takeSnapShot();

Flutter - Cache_network_image. I replaced old image with new image with same name. But it doesn't affect on app

I am new to flutter. I have used library of "cache_network_image" which help to show images from the internet and keep them in the cache directory. In first load, it download the images and stored in cache directory(cache manager) and displayed in app.
Example. I have an image(test.png), it downloaded from network and stored in cache successfully. But If I replace test.png image with new image with same name of test.png. So It should display new image
with that same name(test.png). It's displaying only old image.
The cache_network_image library not working properly. Please share your thoughts.
no, it doesn't care whats in the end of the url, all it cares is whether file exists locally, if it doesn't then only it'll fetch from the url, if you want to refetch the updated image you have clear the cache, delete the app data or if you want to clear programmatically
var cm = DefaultCacheManager();
cm.emptyCache();

How to check if any apps are associated with file extension

I want to make "Open in.." function in my iOS application.
Is there any way to check if any app on this device is associated with file extension that i want to share?
If there are no apps on current device to open file with such an extension than UIDocumentInteractionController will not be displayed after clicking on "Open in.." button, but i want not to show this button in such case.
So the question is: how to check if any app on device can open some file with specific extension?
Update:
For example UIDocumentInteractionController has NSArray property icons.
It contains images of all aplications that can open the file with my extension. But if there are no applications it contans image of empty application.
So i can't check it using docInteractionController.icons.count == 0 for example. I am looking for other tricks.'
Thanks, in advance.
Although UIDocumentInteractionController does not offer a way to discover in advance whether there are any applications that can handle a document, -presentOpenInMenuFromRect: will return a flag indicating whether there were any applications that could open a document. This requires you to have already set up and presented the controller, which is not optimal.
There is a workaround for this, a little hacky but is functional: Before you invoke the "real" interaction controller, create a dummy one using a dummy document, and present it from the rect of the window's bounds. This guarantees that it will "appear" offscreen, so your user won't see it. At that point, you have the flag returned from -present, and you can immediately dismiss the dummy controller, and the proceed to show your UI appropriately.
On OSX, you can get a list of application bundle identifiers capable of handling a specific content type using LSCopyAllRoleHandlersForContentType. But on iOS, I don't think there is such a way.
If I find, I'll edit my answer.
Considering you are looking for other tricks, you can check if that one image in the icons array is the generic document icon.
If it is then you know that there is no app associated to handle that file type. But this approach will be OS version dependent as generic file icon may change.
From the official documentation:
To declare its support for file types, your app must include the
CFBundleDocumentTypes key in its Info.plistproperty list file. (See
“Core Foundation Keys”.) The system adds this information to a
registry that other apps can access through a document interaction
controller.
To me this indicates that the registry can only be accessed through UIDocumentInteractionController and so no, you would not be able to know in advance if there are any available apps for the file format (which would be totally in line with Apple's philosophy of not letting apps interact directly with each other).
UPDATE:
as you said the icons property contains an image even with no applications present. I checked and all the other methods and properties of the controller do not give an hint about the apps that may open the current file format.
You said in case that no app can open the specified file format there is an "image of empty application". Maybe you can extract that icon and when the array icons only has one image check if the extracted image and the icon are the same?

Keeping variable values when the iPhone is shut-down?

Lets say i have an application which has three text-fields, and i can type whatever i want into them, lets also assume that i have a checkbox and a button. And if the button is tapped while the checkbox is checked, the nsstring values in these textfields should get saved somehow. Lets say i power down my iPhone and restarted it, opened the app once again and wanted those values to be in their respective textfields.
How does one do this?
Is this a case for NSUserDefaults or something for Apple's own Keychain API to handle?
Cheers.
Edit: We used local declarations when setting and getting the values of the NSUserDefaults, which of course, doesnt work. It works perfectly now...
Yes you can make use of NSUserDefaults
Integrate a sqlite3 database into ur app.. save the textfields value in an array and sav it in the database. On starting of the apps just load from the database and retrieve the top most array and show the values back as output.. Hope it helps.. I am new also.. but cant think of anything else if u want to restart ur whole phone and still wants the fields to be filled.
Use NSUserDefaults for stuff that doesn't need to be stored securely and Keychain if it does.
You can use the NSUserDefaults or a PList or a database to save the content.
Example is given below:-
[[NSUserDefaults standardUserDefaults] setObject:#"Jayahari" forKey:#"userName"];
PList can be used for archiving, serilizing. Database also can be used for same purpose.

How I do to call a nib file at only first launch of my application?

I'm new here but I'd like to learn very well iPhone SDK...
I'm making an iPhone app where I'd like to show a modalView controller at launch of my app... How can I do this?
In this modalView, I request some informations and the view must appear only when these informations aren't saved!
Anyone can help me?
P.S.: Sorry for my bad English but I'm Italian... :D Thanks!
First, try to avoid to use NSUserDefautls as it's not application specific and can cause troubles under some circumstances (see reference docs).
I'd suggest to save your app specific data to some plist file for which you can check for at app startup -(void) applicationDidFinishLoading: method of your app delegate class - and decide if your modal view should be shown or not.
Let's say you have application wide accessible
NSMutableDictionary instance where you store your
preferences. When app is about to quit i.e. - (void)
applicationWillTerminate: method of your app delegate, simply store content of that dictionary to plist somewhere under you app directory structure (Documents folder is a good choice). See NSDictionary reference on how to store/read plist files. It's pretty simple.
Typically, you check for your saved data and if it's not there, you assume that it is the first run.
Thus, you first need to decide how you are going to persist data:
User defaults (NSUserDefaults).
Store a file. Typically a property list (plist) in the Documents directory.
Core Data.
I'd like to use NSUserDefaults...