Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

has anyone seen "[StdMovieUISliderCell sliderType]: unrecognized selector sent to instance"

Tags:

cocoa

osx-lion

I am using QTMovieView and , sometimes, I get the following log and follow by an unknown selector exception. The program has options for users to set to show and hide controller of the QTMovieView. The SDK that the program is linking against is 10.7

"[StdMovieUISliderCell sliderType]: unrecognized selector sent to instance"

thanks for any help

like image 796
psksvp Avatar asked Jun 08 '12 01:06

psksvp


3 Answers

This looks like a bug that was introduced in OS X Mountain Lion 10.8 (Edit: there are also reports on OS X 10.7, see comments below) . I guess that QTMovieView will get deprecated in one of the next major OS X releases. The best solution is to move to AV Foundation (AVPlayer and the corresponding AVPlayerLayer class). Apple has some documentation about playing back assets using this framework.

That said, if you can’t update to AV Foundation or you can’t turn off Auto Layout, you still can fix this issue by adding the missing methods dynamically during runtime to the StdMovieUISliderCell class. Make sure to add the Objective C runtime header file and to add the methods as early as possible (e.g. + (void)load in your application delegate). For App Store static analyzer rejection foo reasons, it’s also safe to add some simple encoding to the class name like rot13.

// Make sure that we have the right headers.
#import <objc/runtime.h>

// The selectors should be recognized by class_addMethod().
@interface NSObject (SliderCellBugFix)

- (NSSliderType)sliderType;
- (NSInteger)numberOfTickMarks;

@end

// Add C implementations of missing methods that we’ll add
// to the StdMovieUISliderCell class later.
static NSSliderType SliderType(id self, SEL _cmd)
{
  return NSLinearSlider;
}

static NSInteger NumberOfTickMarks(id self, SEL _cmd)
{
  return 0;
}

// rot13, just to be extra safe.
static NSString *ResolveName(NSString *aName)
{
  const char *_string = [aName cStringUsingEncoding:NSASCIIStringEncoding];
  NSUInteger stringLength = [aName length];
  char newString[stringLength+1];

  NSUInteger x;
  for(x = 0; x < stringLength; x++)
  {
    unsigned int aCharacter = _string[x];

    if( 0x40 < aCharacter && aCharacter < 0x5B ) // A - Z
      newString[x] = (((aCharacter - 0x41) + 0x0D) % 0x1A) + 0x41;
    else if( 0x60 < aCharacter && aCharacter < 0x7B ) // a-z
      newString[x] = (((aCharacter - 0x61) + 0x0D) % 0x1A) + 0x61;
    else  // Not an alpha character
      newString[x] = aCharacter;
  }
  newString[x] = '\0';

  return [NSString stringWithCString:newString encoding:NSASCIIStringEncoding];
}

// Add both methods if they aren’t already there. This should makes this
// code safe, even if Apple decides to implement the methods later on.
+ (void)load
{
  Class MovieSliderCell = NSClassFromString(ResolveName(@"FgqZbivrHVFyvqrePryy"));

  if (!class_getInstanceMethod(MovieSliderCell, @selector(sliderType)))
  {
    const char *types = [[NSString stringWithFormat:@"%s%s%s",
      @encode(NSSliderType), @encode(id), @encode(SEL)] UTF8String];
    class_addMethod(MovieSliderCell, @selector(sliderType),
      (IMP)SliderType, types);
  }
  if (!class_getInstanceMethod(MovieSliderCell, @selector(numberOfTickMarks)))
  {
    const char *types = [[NSString stringWithFormat: @"%s%s%s",
      @encode(NSInteger), @encode(id), @encode(SEL)] UTF8String];
    class_addMethod(MovieSliderCell, @selector(numberOfTickMarks),
      (IMP)NumberOfTickMarks, types);
  }
}

I made two assumptions while implementing both methods:

  1. A movie view can only have a linear slider, not a circular one.
  2. A movie view won’t have tick marks.

The latter could be a problem if your movie has chapters, but I don’t know how they are handled, because I don’t need or use them.

like image 50
Rafael Bugajewski Avatar answered Oct 17 '22 07:10

Rafael Bugajewski


I had the same problem if I tried to use setMovie: with AutoLayout on. An update to Xcode 4.4.1 fixed the problem.

like image 1
user1582081 Avatar answered Oct 17 '22 07:10

user1582081


i know it's a fairly old post, but for others out there, i had the same problem, i've just deactivated the cocoa autolayout for the xib file containing the QTMovieView and it worked like it should have.

i'm currently working with xcode 4.5.2 under OSX 10.7.4

like image 1
TheFuquan Avatar answered Oct 17 '22 06:10

TheFuquan