I can declare NSMutableArray or NSArray but I want to declare class array. Let say user is a class so I can declare array as:
user* obj[10];
it is valid in Objective c, but I am not sure how I can set array capacity dynamically. Which we usually do with MutableArray as initWithCapacity:..
This is what I am doing with class:
user* objuser;
CustomOutput* output = [[CustomOutput alloc] init];
[objuser cutomSerialize:output];
NSMutableData* data = output.data;
But If I have array as:
NSMutableArray* aryUserObj;
I can’t call cutomSerialize method from arryUserObj.
I want to Serialize all the userObj at ones and get a single NSData object.
The standard approach to serialize an array of objects is for you to define
encodeWithCoder:andinitWithCoder:in yourUserobject:What you currently have in
CustomSerializeshould be in these methods.Then, if you want to encode an object, you do
and decode it:
If you have an array of objects,
and
Iteration over array is done automatically.
Note also that you don’t get the mutable array back, it’s an immutable array.