NSString to NSSize

Discussion in 'Mac Programming' started by larswik, May 28, 2013.

  1. macrumors 68000

    Sep 8, 2006
    Hey, I am scratching my head solving this. I have a QTMovie object and I am using the Method 'movieAttributes' to get the Attributes of the object. It returns an NSDictionary and it NSLogs just fine.

    The returned NSDictionary is holding NSStrings and I am interested in QTMovieCurrentSizeAttribute. When I NSLog the Dict it prints this

    I need to convert this NSString to an NSSize struct. It says it is NSSize.

    I know this wont work since it is an NSString, but how do I convert a String to a struct?

    NSSize frameSize = [qtDict objectForKey:@"QTMovieCurrentSizeAttribute"];
    Is there an easier way to convert it besides spiting up the string?
  2. larswik, May 28, 2013
    Last edited: May 28, 2013

    thread starter macrumors 68000

    Sep 8, 2006
    I found the answer with a little further reading in the Docs. Although it returns an NSDictinalry with strings I could use the NSValue, stated here in the docs
    So needing this (incorrect code)
    NSSize frameSize = [qtDict objectForKey:@"QTMovieNaturalSizeAttribute"];
    it is accomplished like this

    NSValue *xyData = [qtAtributesDict objectForKey:QTMovieNaturalSizeAttribute];
    NSSize xySize = [xyValue sizeValue];
    NSLog(@"Frame Size: %.0f : %.0f", xySize.width, xySize.height);
    In case anyone else runs in to this issue, that is how I solved it.

Share This Page