PDA

View Full Version : Confusing EXC_BAD_ACESS error !




Armin1983
Feb 10, 2012, 04:40 AM
Hello guys,

I am writing a Web scraper APP, First i implemented it and ran it through Console, It works great! but after i tried to make a GUI for that, It does not work.

Application class Called: ScraperApp
Class for GUI called: ScraperCocoaApp

the problem is with method!

-(IBAction) FieldAndXPathQuery:(id)sender

when i press SET button, it gives the EXC_BAD_ACESS error !

>> To observe the problem just fill the textboxes and press SET.

I appreciate anyone's help, if you just download the the attached project and take a look at that.

Thanks



gnasher729
Feb 10, 2012, 05:24 AM
So what does the compiler tell you when do an "Analyze"?
Have you turned on all compiler warnings that make sense?

Armin1983
Feb 10, 2012, 05:36 AM
So what does the compiler tell you when do an "Analyze"?
Have you turned on all compiler warnings that make sense?

Thank you for reply,

I did do an analyze, it is successfully! the error happen when i press the "set" button!

How can i turn on compiler warning ? i am using xcode 3.2

gnasher729
Feb 10, 2012, 06:27 AM
Thank you for reply,

I did do an analyze, it is successfully! the error happen when i press the "set" button!

How can i turn on compiler warning ? i am using xcode 3.2

In your build settings, there are about two dozen warnings that you can turn on. Things like uninitialized variables and so on. But if you run your app from Xcode, it will stop in the debugger when that error happens, and you can look at the variables at that time, which methods were called, and so on.

The very first thing that you should do is to set a breakpoint on the first statement of FieldAndXPathQuery, and then step go through the code step by step, looking at the contents of variables after each step, and finding out what doesn't work the way you think it should work.

Armin1983
Feb 10, 2012, 07:17 AM
In your build settings, there are about two dozen warnings that you can turn on. Things like uninitialized variables and so on. But if you run your app from Xcode, it will stop in the debugger when that error happens, and you can look at the variables at that time, which methods were called, and so on.

The very first thing that you should do is to set a breakpoint on the first statement of FieldAndXPathQuery, and then step go through the code step by step, looking at the contents of variables after each step, and finding out what doesn't work the way you think it should work.

Actually i used break point! i was not able to figure out the error. even i placed it insed a try/catch. it even does not give me the reason ... that is why i uploaded the project here, so if u professional guys can find the problem, since morning i have been working on this problem, but still no result :(

gnasher729
Feb 10, 2012, 09:20 AM
Actually i used break point! i was not able to figure out the error. even i placed it insed a try/catch. it even does not give me the reason ... that is why i uploaded the project here, so if u professional guys can find the problem, since morning i have been working on this problem, but still no result :(

Did it stop at the break point? Inside your method? What was the call stack? Or did it crash before reaching the break point? Which means your action method isn't called, so check your connection in interface builder.

try / catch isn't going to help at all. The only place where using try / catch is appropriate in Objective-C is when working with distributed objects, which you are not. Outside that area, any exception thrown is a bug in your application that needs to be fixed.

Mac_Max
Feb 10, 2012, 04:05 PM
I'm not on a Mac right now so I can't run your program but if you're managing your memory manually, you're likely getting the error because you're not properly managing your retain/release options.

http://loufranco.com/blog/files/Understanding-EXC_BAD_ACCESS.html

saleh.hi.62
Feb 11, 2012, 08:31 AM
Thanks all guys,

Actually the problem was this.

in a class i initialized my NSDictionary object in this way -> [NSMutableDictionary dictionary]

in that class its fine, but i inherited that class for another class. so since it became super class it could not work with that kind of initialization!

Thanks to all.

GorillaPaws
Feb 11, 2012, 10:38 AM
i inherited that class for another class. so since it became super class it could not work with that kind of initialization!

You weren't trying to subclass NSDictionary were you? That's not a good idea. The better approach is to use composition to extend the functionality of a custom NSObject that adds the required functionality to a standard NSDictionary.

It looks like you're improving at debugging your own problems and writing better questions.