views:

2620

answers:

6
A: 

What do you mean by “crash”?

Does anything appear in the Debugger Console (⇧⌘R)?

Does a stack trace appear in the Debugger window?

If there's a stack trace, where in your code does it crash?

Peter Hosey
A: 

It just hangs. In the debugger I see:

  [Session started at 2008-11-28 14:40:34 +1000.]
2008-11-28 14:40:36.157 CH18Challenge_try2[1893:10b] Mouse Down at (80.000000,285.000000)
2008-11-28 14:40:36.333 CH18Challenge_try2[1893:10b] Mouse Up at (166.000000,217.000000)
2008-11-28 14:40:36.348 CH18Challenge_try2[1893:10b] Init 
2008-11-28 14:40:36.349 CH18Challenge_try2[1893:10b] CREATED NEW drawnObject

[Session started at 2008-11-28 14:40:36 +1000.]
Loading program into debugger…
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".Program loaded.
sharedlibrary apply-load-rules all
Attaching to program: `/Users/johan_kritzinger/Documents/Cocoa/CH18Challenge_try2/build/Debug/CH18Challenge_try2.app/Contents/MacOS/CH18Challenge_try2', process 1893.
(gdb) 

Then I have to force quit to stop it.

Sorry, that was the debugging console. In the Debugger I see it indicates that <em>indexedObject is out of scope</em>. And that is what I don't understand. I'm probably just slow on the uptake..As I mentioned, I'm a noob - where would I look for a stack trace?
If it crashed before it got to the for-loop then the indexedObject variable doesn't exist yet.What does the implementation of createPath: look like?
Ashley Clark
case 0: tempPath = [NSBezierPath bezierPathWithOval:aRect];break;//other cases eg for rectabngle}//close switchretuen tempPath;}
The stack trace is in the upper-left list in the Debugger window.Your problem is that bezierPathWithOval: doesn't exist. The correct selector is bezierPathWithOvalInRect:.
Peter Hosey
A: 

We need to see the implementation of setAPath from DrawnObject.m. Also, for the "stack trace" look on the upper left of the debugger--it should list a stack of functions showing where in your code the crash is. Make sure you're running in Debug mode, not Release.

Adam Ernst
If I understand it correctly, this is what the stack trace is saying (there are 22 items but only one is black): -[Canvas drawRect:] and if I click on that the right hand pane of debuggers says indexedObject out of scope. Could it be that my implementation of the for loop is wrong in drawRect?
No, the crash has nothing to do with indexedObject or the loop. "out of scope" just means that you haven't gotten to the for loop yet, so the object is "out of scope".
Adam Ernst
A: 

On the command line you can type print-object and you can set a breakpoint in that line and step through it from there. It seems setAPath is somehow broken

Regards Friedrich

Friedrich
+1  A: 

You said your init method was:

-(void)init {
[super init];
//set default color = black
toolColor.rd=1.0;
toolColor.grn=1.0;
toolColor.blu=1.0;
toolColor.alp=1.0;
//set default size
toolSize=0.8;
//set default toolType
toolType=0;
//oval
NSLog(@"Init %@",self);
}

This is definitely wrong; read up on how to create an init method in the Obj-C guide or by reading sample code. Here's what it should look like:

-(id)init {
if (self = [super init]) {
    //set default color = black
    toolColor.rd=1.0;
    toolColor.grn=1.0;
    toolColor.blu=1.0;
    toolColor.alp=1.0;
    //set default size
    toolSize=0.8;
    //set default toolType
    toolType=0;
    //oval
    NSLog(@"Init %@",self);
}
return self;
}

By not returning anything from -init, you were preventing the object's creation. Good luck! :-)

Edit: Ashley beat me to it...

Adam Ernst
A: 

What you have is not a crash. A crash is when a signal is raised (like EXC_BAD_ACCESS) or an uncaught exception.

What you have seems to be an infinite loop.

You need to use the pause button in the Debugger and see exactly where. I would guess that you have an infinite loop in your setAPath: method. You need to work out why this function is looping indefinitely.

Matt Gallagher