alexeyxo / protobuf-swift

Google ProtocolBuffers for Apple Swift
http://protobuf.io/#swift
Apache License 2.0
938 stars 138 forks source link

Automatically set property #176

Closed sm2017 closed 8 years ago

sm2017 commented 8 years ago

I have set of proto files that have same property (rand_id)

message A{
   string rand_id = 1
   //...
}

message B{
   string rand_id = 1
   //...
}

message C{
   string rand_id = 1
   //...
}

How can I have a function that set rand_id automatically , Something like this

a = A instance 
b = B instance 
c = C instance 

func setRand(proto GenerateMessageProtocol){
    proto.rand_id = random()
}

setRand(a)
setRand(b)
setRand(c)
sm2017 commented 8 years ago

Any idea?