Using dispatch group to wait until multiple operations executed – including completion block (AFNetworking)

Android Java Serialization Using Generics

I have created a class – SerializationManager, it can serialize any objects and write them to files. It can be used to save and restore form states in Android. It is based on Java Generics. What is achieved by this is that you do not need to duplicate serialization code in every class.

images

Object must implement Serialized interface. Here form is an object instance of a class. It can be named as just obj.

This is how you can use it. First you declare a SerializationManager in your class and you tell it which class you are going to serialize:

Then in onCreate method you create SerializationManager instance:

Writing object to a file:

Reading objects from saved file:

A little joke for reading to the end:
java generics

Tips discovered while using Android spinners : setting selected item and finding objects in arrays in Java

To set a selected item programmatically in Android Spinner, you should use setSelection method.

To get an index of an item to select from an array of strings using IndexOf, you should first use java.util.Arrays.asList method.

Complete code:

Serialize an object, save it to a file and read it from a file in Android

Android interface Serializable is not sufficient to save your objects to the file, it only creates streams.

This is a complete code with error handling and handling closes of streams. Add it to your class that you want to be able to serialize and deserialize.

In my case the class name is CreateResumeForm. You should change it to your own class name.

Use it like this in your Activity:

Sorting objects in Objective-C in Alphabet Order by Name

It is a very easy but a common task. There is no need to create any custom NSSortDescriptors. Let’s say, we have an unsorted array of RRRegion objects, that have a name property. This is how we can sort this array: