Reputation: 1232
In Swift, we use
matrixMultiplication = MPSMatrixMultiplication(device: device, transposeLeft: false, transposeRight: false, resultRows: rowsC, resultColumns: columnsC, interiorColumns: columnsA, alpha: 1, beta: 0)
But when I try to call the method initWithDevice
on MPSMatrixMultiplication
, like [MPSMatrixMultiplication initWithDeivce ...]", it shows "No known class method for selector 'initWithDevice'"
So what's the correct way to declare a MPSMatrix in Objective-C? Isn't this method a class method since it returns a pointer to the object it initialized.
Upvotes: 0
Views: 177
Reputation: 535944
Isn't this method a class method
No, Objective-C initializers are instance methods. You have to create an instance with alloc
. So
MPSMatrixMultiplication* mult = [[MPSMatrixMultiplication alloc] initWith...];
That (alloc-init
) is always the pattern for initialization in Objective-C.
Upvotes: 2