How to read a CMVideoDimensions structure with Objective C code?

I am new to Objective C and relatively new to iOS development.

I have an AVCaptureDevice object at hand and would like to print the maximum supported photo dimensions as provided by activeFormat.supportedMaxPhotoDimensions, using Objective C. I tried the following:

for (NSValue *obj in device.activeFormat.supportedMaxPhotoDimensions) {
  CMVideoDimensions *vd = (__bridge CMVideoDimensions *)obj;
  NSString *s = [NSString stringWithFormat:@"res=%d:%d", vd->width, vd->height];
  //print that string
}

If I run this code, I get:

res=314830880:24994

This is way too high, and there is obviously something I am doing wrong, but I don't know what it could be. According to the information I see on the developer forum, I should get something closer to 4000:3000.

I can successfully read device.activeFormat.videoFieldOfView and other fields, so I believe my code is sound overall.

Replies

those NSValue things are special. They are containers, with their own accessors for their contents.

for (NSValue *obj in dev.activeFormat.supportedMaxPhotoDimensions) {
      CMVideoDimensions vd = obj.CMVideoDimensionsValue;
      NSString *s = [NSString stringWithFormat:@"res=%d:%d", vd.width, vd.height];
      //print that string
}