views:

135

answers:

3

If i implement it in application delegate class then it works fine. But in Viewcontroller class crash every time. i implemented try-catch then it will not crash. but not working.

Thanks Manoj

+2  A: 

Learn to use the debugger.

It’ll tell you, where the crash happens. Then you might get an idea about which object or which method is to blame. Your case sounds like a memory management problem, but it’s impossible to tell from your description.

Also: try-catch is a concept rarely used in Cocoa. If you come from Java, you’ll might think that is catches all errors, but in Objective-C, few errors throw exceptions.

Nikolai Ruhe
This would be a good time to link to the Xcode Debugging Guide: http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeDebugging/
Peter Hosey
A: 

This is my code if we comment the line [mainMenuView addSubview:adWhirlView]; then Application works ok

my .h file

#import "AdWhirlDelegateProtocol.h"
@interface Are_you_BoredViewController : UIViewController  <AdWhirlDelegate> {
    AdWhirlView *adWhirlView;]

my .m file

-(void)awakeFromNib{
    adWhirlView = [AdWhirlView requestAdWhirlViewWithDelegate:self];

-(void)nextButtonEnable{
        [menuLoop stop];
        [splashActIndicator stopAnimating];
        [splashActIndicator setHidesWhenStopped:YES];
        [nextSplashBtn setHidden:NO];
        [self.view addSubview:mainMenuView];
        [mainMenuView addSubview:adWhirlView];
        [mainMenuView setFrame:CGRectMake(0.0, 0.0, 320.0, 480.0)];
}
Amit Battan
You should edit this into your question, not post it as an answer to the question.
Peter Hosey
A: 
-(void)awakeFromNib{
    adWhirlView = [AdWhirlView requestAdWhirlViewWithDelegate:self];

Since you're assigning this object's pointer into one of your instance variables, you should retain the object. See the memory management rules.

Also, terminate the method with a }. ☺

Peter Hosey