• 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: Newbie (EXE_BAD_ACCESS?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie (EXE_BAD_ACCESS?)


  • Subject: Re: Newbie (EXE_BAD_ACCESS?)
  • From: Thomas Lachand-Robert <email@hidden>
  • Date: Sun, 23 Mar 2003 15:00:26 +0100

Le dimanche, 23 mars 2003, ` 04:48 Europe/Paris, Nick Zitzmann a icrit :

On Saturday, March 22, 2003, at 08:51 AM, Bernard Banks wrote:

I have a program that draws on NSView myView with drawRect. I am trying to
include a toy subroutine to draw a line in myView by using a class method
+(void)drawLine:(float)X:(float)Y defined in the subclass Line.h and Line.m
of NSObj. In drawRect I make the call [Line drawLine:100.0:100.0]. In
compiling, I get two warnings, 1) invalid receiver type 'void (short
int,short int)', and 2) passing arg 1 of pointer to function from
incompatible pointer type.

Under debug, the program chokes at [Line drawLine:100.0:100.0] and gives me
the EXE_BAD_ACCESS error. If this line is left out the program runs with no
problem.

You're getting this error because the compiler is casting the numbers in your +drawLine call as integers and not floats. The BAD_ACCESS error you're getting is basically a segmentation fault, which indicates a memory problem.



Not at all. The compiler would correctly convert an int to float in a method call if an argument is declared so. Also 100.0 is actually a double, not a short int. (Use 100.0f if you want to make sure that it's a float).

Your error message says: "invalid RECEIVER"; this means that the object receiving the message is not as expected. Try [[Line class] drawLine:100.0:100.0], but I suspect there is something wrong in your Line.h file: are you sure you define a class here?

Also notice that you don't need to define such a drawLine routine. See NSBezierPath strokeLineFromPoint:toPoint:

Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.
_______________________________________________
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: Newbie (EXE_BAD_ACCESS?) (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Multiple windows
  • Next by Date: Re: Multiple windows
  • Previous by thread: Re: Newbie (EXE_BAD_ACCESS?)
  • Next by thread: Re: Newbie (EXE_BAD_ACCESS?)
  • Index(es):
    • Date
    • Thread