• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: +[NSConstantString length]: selector not recognized
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: +[NSConstantString length]: selector not recognized


  • Subject: RE: +[NSConstantString length]: selector not recognized
  • From: "Jonathan E. Jackel" <email@hidden>
  • Date: Mon, 17 Mar 2003 09:54:15 -0500

Just to recap, as soon as my app entered -create:array: it would raise the
exception in the subject line. In the interest of helping anyone stuck for
days trying to debug something mysterious like this, I offer the following.

After much experimentation -create:array: is now working. I determined that
no matter what string I used for the first argument, I got similar errors.
Always, a concrete NSString subclass (either NSConstantString or NSCFString)
was being sent a length message -- that is, an instance message was being
sent to a class. The fact that a different subclass was being used,
depending on how I constructed the string, caused me to believe --
mistakenly -- that the problem was in how I was forming the string. I spent
many wasted hours constructing the string in different ways.

I finally commented out the entire method except the return value and the
error went away. Then I de-commented line by line, starting at the
beginning of the method. I built and debugged the app at each stage. I
figured I would eventually (though tediously) uncover the offending line.

The first few lines created no problem whatsoever. Deeper in the method I
noticed a few logic-type errors, but nothing that sent a length message
directly. I fixed the errors, gradually restoring the entire method. Now
everything works fine.

The only reasonable explanation is that somehow, something I fixed prevented
the offending length message from being sent by the Cocoa framework. I have
no idea what the cure was.

Jonathan

>
>
> > > NSArray *nothing = [self create:createArg array:picks];
> >> > And up until this point everything seems ok. createArg contains
> > > something like "[Right] :Things" -- no apparent problems.
> > > The beginning of create:array: looks like this:
> > > - (NSArray *)create:(NSString *)arguments array:(NSArray *)picks
> > > {
> > > NSArray *args = [arguments componentsSeparatedByString:@":"];
> >
> >
> > Break in the debugger and se what arguments is. Do you have an
> > arguments instance variable that perhaps it is using instead and is
> > uninitialized?
>
> The arguments string appears to be a valid string in the
> debugger. There is
> no instance variable called arguments.
>
>
> > Is self a pointer to an instance of your class, or your
> > class itself?
>
> An instance. -create:array is an instance method. Should not be
> a problem.
>
>
> > If the first code you have above is a class method,
> > than self here would be the class and not the instance, and arguments
> > would also be a class not an instance, and you would probably throw an
> > exception for selector not recognized.
>
> No, we're dealing with an instance of the class all the way.
>
>
> >
> > > And this is where the fun starts. As soon as I hit this statement, I
> > > get:
> > >
> > > 2003-03-13 21:10:33.004 DGStitcher[1187] *** +[NSConstantString
> > > length]: selector not recognized
> > >
> > It threw an exception, and since you weren't catching them it goes up
> > to the default handler which prints this.
>
> Yes. I have a breakpoint set on -[NSException raise].
>
> >
> > Instances of NSConstantString should respond to length
> > The Class of NSConstantString does not.
> >
> > The +[NSConstantString means that the length method is being sent to
> > the class and not to an instance.
> >
>
> Yes, I realize that the + indicates a class method. But I am sending no
> such messages. I am sending a -componentsSeparatedByString
> message to what
> appears to be a valid NSString instance. But it throws an
> exception for no
> reason that is apparent to me. I don't see
> hy -componentsSeparatedByString would send a length message to a class.
>
> Jonathan
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >RE: +[NSConstantString length]: selector not recognized (From: "Jonathan E. Jackel" <email@hidden>)

  • Prev by Date: Re: State of Cocoa adoption
  • Next by Date: Re: Programatically opening a NSComboBox?
  • Previous by thread: RE: +[NSConstantString length]: selector not recognized
  • Next by thread: Checking the type...
  • Index(es):
    • Date
    • Thread