0

Alright, so I have started my adventure into the world of Objective-C and am currently stumped with the following scenario. The scenario is as follows, I created a class, a simple method for it, created an object of my class, then tried setting a value of my object using the method I created. When I try running the app I get a breakpoint at

[chris setAge:29];

and the Console Output states,

(lldb)

All this is, is a simple command-line tool, and consists one file, main.m

//  main.m

#import <Foundation/Foundation.h>

@interface Person : NSObject {
    int age;
}
-(void)setAge:(int)a;
@end

@implementation Person
-(void)setAge:(int)a {
    age = a;
}
@end

int main(int argc, const char * argv[])
{

    @autoreleasepool {

        // insert code here...
        int age = 29;
        int money = 0;
        int broke = age + money;
        NSLog(@"Hello, World!\n");
        NSLog(@"I am %i",broke);

        Person *chris = [[Person alloc]init];
        [chris setAge:29];
        NSLog(@"Chris's age is %@",chris);


    }
    return 0;
}
ipatch
  • 3,933
  • 8
  • 60
  • 99
  • 1
    possible duplicate of [getting breakpoint retrieving addressbook data](http://stackoverflow.com/q/10406572/) and [Stopped at breakpoint error when initializing object](http://stackoverflow.com/q/10016890/) and [Stopped at breakpoint anyone can solve this?](http://stackoverflow.com/questions/8531373/) – jscs Jun 06 '12 at 06:42

1 Answers1

1

I think you have set a breakpoint and the debugger simply stop at the breakpoint, there is nothing wrong with your code ...

aleroot
  • 71,077
  • 30
  • 176
  • 213
  • Yeah, I have no idea how that breakpoint got set (>.>) But now when I run the program the console is outputting the following: Chris's age is – ipatch Jun 06 '12 at 07:00
  • That's because you haven't provided a method called `description` for your Person class. When you log an output using %@, you are actually printing the result of calling this method. It's part of NSObject, but you have to provide the implementation yourself. – Abizern Jun 08 '12 at 09:19