diff --git a/ios/dtx_codec/channel.go b/ios/dtx_codec/channel.go index 700b7973..cb9cfc8a 100644 --- a/ios/dtx_codec/channel.go +++ b/ios/dtx_codec/channel.go @@ -49,19 +49,36 @@ func (d *Channel) ReceiveMethodCall(selector string) Message { // MethodCall is the standard DTX style remote method invocation pattern. The ObjectiveC Selector goes as a NSKeyedArchiver.archived NSString into the // DTXMessage payload, and the arguments are separately NSKeyArchiver.archived and put into the Auxiliary DTXPrimitiveDictionary. It returns the response message and an error. func (d *Channel) MethodCall(selector string, args ...interface{}) (Message, error) { - payload, _ := nskeyedarchiver.ArchiveBin(selector) auxiliary := NewPrimitiveDictionary() for _, arg := range args { auxiliary.AddNsKeyedArchivedObject(arg) } + + return d.methodCallWithReply(selector, auxiliary) +} + +// MethodCallPrimitive is a DTX style remote method invocation pattern. The ObjectiveC Selector goes as a NSKeyedArchiver.archived NSString into the +// DTXMessage payload, and the primitive arguments put into the Auxiliary DTXPrimitiveDictionary. It returns the response message and an error. +func (d *Channel) MethodCallPrimitive(selector string, args ...int) (Message, error) { + auxiliary := NewPrimitiveDictionary() + for _, arg := range args { + auxiliary.AddInt32(arg) + } + + return d.methodCallWithReply(selector, auxiliary) +} + +func (d *Channel) methodCallWithReply(selector string, auxiliary PrimitiveDictionary) (Message, error) { + payload, _ := nskeyedarchiver.ArchiveBin(selector) msg, err := d.SendAndAwaitReply(true, Methodinvocation, payload, auxiliary) if err != nil { log.WithFields(log.Fields{"channel_id": d.channelName, "error": err, "methodselector": selector}).Info("failed starting invoking method") return msg, err } if msg.HasError() { - return msg, fmt.Errorf("Failed invoking method '%s' with error: %s", selector, msg.Payload[0]) + return msg, fmt.Errorf("failed invoking method '%s' with error: %s", selector, msg.Payload[0]) } + return msg, nil } diff --git a/ios/instruments/processcontrol.go b/ios/instruments/processcontrol.go index eb115366..f33a10e4 100644 --- a/ios/instruments/processcontrol.go +++ b/ios/instruments/processcontrol.go @@ -64,7 +64,7 @@ func NewProcessControl(device ios.DeviceEntry) (*ProcessControl, error) { // DisableMemoryLimit disables the memory limit of a process. func (p ProcessControl) DisableMemoryLimit(pid uint64) (bool, error) { - msg, err := p.processControlChannel.MethodCall("requestDisableMemoryLimitsForPid:", pid) + msg, err := p.processControlChannel.MethodCallPrimitive("requestDisableMemoryLimitsForPid:", int(pid)) if err != nil { return false, err }