ipatch
ipatch

Reputation: 4043

Simple Xcode, Objective-C class not working

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;
}

Upvotes: 0

Views: 175

Answers (1)

aleroot
aleroot

Reputation: 72686

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

Upvotes: 1

Related Questions