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