• 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: Objective C playing funny, or just me?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective C playing funny, or just me?


  • Subject: Re: Objective C playing funny, or just me?
  • From: Raphael Sebbe <email@hidden>
  • Date: Wed, 10 Oct 2001 09:42:45 +0200

You forgot a retain] : [[NSBezierPath
bezierPathWithRect:NSMakeRect(0,0,0,0)] retain];
newPath is autoreleased.

Do not forget to release it in your dealloc method :

- (void)dealloc
{
[newPath release];

[super dealloc];
}

Raphael

On Wednesday, October 10, 2001, at 07:49 AM, Ruben Westerberg wrote:

> Hi all,
> I have some code that compiles, no errors and runs. The code interprets
> mouse events. The problem is the program crashes when I access the
> class variables, but only in some methods.
> here is the code (mostly debugging mess):
>
> -(id)initWithComponent:(SNPComponent *)theComponent
> {
> // the super class gives the default @protected access to newPath
> and currentElement
> self = [super initWithComponent:theComponent];
> newPath = [NSBezierPath bezierPathWithRect:NSMakeRect(0,0,0,0)];
> //THIS WORKS, CAN ACCESS VARIABLES HERE, GET EXPECTED RESULTS
> NSLog([currentComponent name]);
> printf("elements is Bezier path: %d\n",[newPath elementCount]);
>
> return self;
> }
>
> (void)mouseDownAtPoint:(NSPoint ) mPoint
> {
> mouseDownPoint= mPoint;
> //do other stuff here. Doesn't access currentComponent
>
> //THE SAME 2 LINES OF CODE HERE CAUSE A SIGBUS 10 ERROR
> printf("elements is Bezier path: %d\n",[newPath elementCount]);
> NSLog([currentComponent name]);
> }
>
> (void)mouseDraggedAtPoint:(NSPoint ) mPoint
> {
> mouseDownPoint= mPoint;
> //do other stuff here. Doesn't access currentComponent
> newPath = [NSBezierPath
> bezierPathWithRect:NSMakeRect(mouseDraggedPoint.x,
> mouseDownPoint.y, mouseDownPoint.x-mouseDraggedPoint.x,
> mouseDraggedPoint.y-mouseDownPoint.y)];
>
> //THE SAME 2 LINES OF CODE HERE ***DO NOT*** CAUSE A SIGBUS 10 ERROR
> // AND GIVE THE EXPECTED RESULTS
> printf("elements is Bezier path: %d\n",[newPath elementCount]);
> NSLog([currentComponent name]);
> }
> (void)mouseUpAtPoint:(NSPoint ) mPoint
> {
> mouseDownPoint= mPoint;
> //do other stuff here. Doesn't access newPath or currentComponent
>
> //THE SAME 2 LINES OF CODE HERE CAUSE A SIGBUS 10 ERROR
> printf("elements is Bezier path: %d\n",[newPath elementCount]);
> NSLog([currentComponent name]);
> }
>
> @end
>
> Does anyone know what is going on here... I am fairly new to Objective
> C, is there something that i am missing? sorry if this is an obvious
> mistake on my behalf...but any help would be great....
> sorry for the large amount of code...
> thanks
> Ruben
> _______________________________________________
> cocoa-dev mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev


References: 
 >Objective C playing funny, or just me? (From: Ruben Westerberg <email@hidden>)

  • Prev by Date: Re: Persistance
  • Next by Date: Re: Additional info needed about "PackageMaker"
  • Previous by thread: Re: Objective C playing funny, or just me?
  • Next by thread: Obj-C++ (was: DLL hell (was: Cocoa newbie frustration))
  • Index(es):
    • Date
    • Thread