Confusing EXC_BAD_ACESS error !

Discussion in 'Mac Programming' started by Armin1983, Feb 10, 2012.

  1. Armin1983 macrumors newbie

    Jan 29, 2012
    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.


    Attached Files:

  2. gnasher729 macrumors P6


    Nov 25, 2005
    So what does the compiler tell you when do an "Analyze"?
    Have you turned on all compiler warnings that make sense?
  3. Armin1983 thread starter macrumors newbie

    Jan 29, 2012
    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
  4. gnasher729 macrumors P6


    Nov 25, 2005
    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.
  5. Armin1983 thread starter macrumors newbie

    Jan 29, 2012
    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 :(
  6. gnasher729 macrumors P6


    Nov 25, 2005
    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.
  7. Mac_Max macrumors 6502

    Mar 8, 2004
  8. saleh.hi.62 macrumors member

    Jul 25, 2011
    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.
  9. GorillaPaws macrumors 6502a


    Oct 26, 2003
    Richmond, VA
    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.

Share This Page