What is the best way to Deserialize “Serialized Protobuf” in objective-c which is generated using C# protobuf-net

StackOverflow https://stackoverflow.com/questions/21381938

Вопрос

I have a Class that contains objects, arrays, int, and string too.

public class Template
    {
        [ProtoMember(1)]
        public string name;
        [ProtoMember(2)]
        public tempClass contour;
        [ProtoMember(3)]
        .
        .
        .
  }

//And here is the Serializing code (Using protobuf-net)
 using (var file = File.Create("Templates.bin"))
            {
                Serializer.Serialize<Template[]>(file, tempArray);
            }

I know it can be deserializeable using Objective-c. i tried some solution but did not succeeded yet.

have anyone done this before? is that better to use XML instead of Protobuf?

Это было полезно?

Решение

That will map to (in .proto terms):

message templateWrapper {
    repeated template items = 1;
}
message template {
    optional string name = 1;
    optional tempClass contour = 2;
    // ...
}
message tempClass {
    // ...
}

And then deserialize as a single templateWrapper, which will have multiple items.

Note that all of the .proto schema except for the templateWrapper should be available via Serializer.GetProto<Template>().

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top