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