0

hi Folks this is jagadeesh, im beginner of this platform while practicing application with reference some books, My Application Running Suceessfully but No output display in the Console here is my Application #import

@interface ClassA : NSObject

{
    int x; 
}

-(void) initVar;
@end

@implementation ClassA
-(void) initVar
{
    x = 100;
}

@end
@interface ClassB : ClassA
{
    int y;
}

-(void) initVar;
-(void) printVar;

@end

@implementation ClassB
-(void) initVar
{ 
    x = 200;
    y = 300;
}
- (void) printVar
{
    NSLog(@"x= %i", x );
    NSLog(@"y= %i", y);
}

@end

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    ClassB *b = [[ClassB alloc] init];
    [b initVar];
    [b printVar];
    [b release];
    [pool drain];
    return 0;
}

and the ****console information is look like this**** Program loaded. run [Switching to process 1310 local thread 0x2e03] Running… (gdb)

1
  • On an unrelated note, you should avoid accessing member variables of parent classes (such as x) within a child's methods (such as ClassB's -initVar). Instead, create init & accessor methods for the parent that set the member and call those from the child. With ObjC 2.0, you can use properties: developer.apple.com/mac/library/documentation/Cocoa/Conceptual/… Commented Oct 20, 2009 at 9:35

1 Answer 1

1

The code runs fine. If you're not getting any messages, it's likely you've inadvertently set a breakpoint in GDB. In this case, typing "info breakpoints" at the "(gdb)" prompt will show them:

(gdb) info breakpoints
Num Type           Disp Enb Address    What
1   breakpoint     keep y   0x000027de in -[SMStatisticController init] at SMStatisticController.m:44
    breakpoint already hit 1 time
Current language:  auto; currently objective-c
(gdb) 

To delete all breakpoints do "del" to delete breakpoints and "c" to continue execution:

(gdb) del
(gdb) c
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Diclu now it works fine Thanks Alot for your valuable suggestions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.