Confusing EXC_BAD_ACESS error !

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

  1. macrumors newbie

    Joined:
    Jan 29, 2012
    Messages:
    11
    #1
    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!

    Code:
    -(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
     

    Attached Files:

  2. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    Messages:
    14,249
    #2
    So what does the compiler tell you when do an "Analyze"?
    Have you turned on all compiler warnings that make sense?
     
  3. macrumors newbie

    Joined:
    Jan 29, 2012
    Messages:
    11
    #3
    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. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    Messages:
    14,249
    #4
    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. macrumors newbie

    Joined:
    Jan 29, 2012
    Messages:
    11
    #5
    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. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    Messages:
    14,249
    #6
    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. macrumors 6502

    Joined:
    Mar 8, 2004
    Messages:
    404
    #7
  8. macrumors member

    Joined:
    Jul 25, 2011
    Messages:
    95
    #8
    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. macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Messages:
    923
    Location:
    Richmond, VA
    #9
    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