Objective-C XCTMeasureOptions object as argument

I need to pass the number of iterations to the measureBlock method i.e. I would like to write in Objective-C the following Swift code:

Code Block swift

let options = XCTMeasureOptions()
options.iterationCount = 5;

measure(options: options) {
        /* The code that's being measured */
}

I wrote:

Code Block Objective-C

XCTMeasureOptions *opt = [XCTMeasureOptions new];
opt.iterationCount = 5;

[self measureBlock:^{
         /* The code that's being measured */
    }];

What syntax should I use to pass the opt object to measureBlock?

Thanks
Stefano Gragnani

Replies

What syntax should I use to pass the opt object to -measureBlock:?

Use the -measureWithOptions:block: method:

Code Block
[self measureWithOptions:opt block:^{
… your code here …
}];


Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Thanks Eskimo, I had not seen the -measureWithOptions:block: method: