 |
 |
Debugging Objective-C
|
 |
|
 |
|
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status:
Offline
|
|
I staretd out programming in Java, so when something would crash in butn there, I would get a nice back trace that was very helpful. In objective-c, I find it takes my 2-3 times as long to find out where a bug in my software is at. Right now, somehow NSCFType is being send a width message, but not in my code explicitely. What I'd like to know is - is there a better way than guess and check to hunt these problems down? I suppose I could add a category to NSCFType with the width method added, but I'd assume there's a better way.
Thanks,
Matt Fahrenbacher
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
In general, a good debugging trick for ObjC is to set a breakpoint on -[NSException raise]. Then the debugger will stop and give you a stack trace when something goes wrong.
Your specific issue sounds like a case where somebody is sending messages to an object that has been deallocated -- the same pointer got reused for another object later, which isn't the object you're looking for. Make sure you're calling -retain when appropriate.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status:
Offline
|
|
Originally posted by Rickster:
In general, a good debugging trick for ObjC is to set a breakpoint on -[NSException raise]. Then the debugger will stop and give you a stack trace when something goes wrong.
Your specific issue sounds like a case where somebody is sending messages to an object that has been deallocated -- the same pointer got reused for another object later, which isn't the object you're looking for. Make sure you're calling -retain when appropriate.
I think you're right on the cause - it switched from NSCFDictionary to NSCFSet (or was it NSSet?), which always tells me I'm doing that. The odd thing is it has something to do with my outlineview delegate methods... although I'm finding it impossible to find which method. Does NSLog() always get flushed?
I'll keep looking, but how would I use [NSException raise]? Wouldn't that require me to know where in my code the problem is at?
Matt Fahrenbacher
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Not call -[NSException raise], set a breakpoint on it in GDB. So that it breaks whenever an exception is raised and you can see what's going on.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
If you do your debugging inside PB (instead of with gdb on the command line), switch to the Breakpoints tab, hit New, and type "-[NSException raise]".
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status:
Offline
|
|
You can use NSDebug.h to help debug these sorts of problems. Cmd-D and type "NSDebug.h" from Project Builder.
|
Geekspiff - generating spiffdiddlee software since before you began paying attention.
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|