Objective c 我的代码有什么问题?(Obj-C)

Objective c 我的代码有什么问题?(Obj-C),objective-c,macos,xcode4,area,Objective C,Macos,Xcode4,Area,所以我现在正试图学习如何在Obj-C中编码,我目前的目标是编写一个简单的命令行程序来计算矩形的面积和周长;然而,当我尝试这个程序时,Xcode总是向我抛出错误。 这是我的密码: #import <Foundation/Foundation.h> @interface Rectangle : NSObject { @private int width; int height; } -(void) setWidth: (int) w; -(void) setHeigh

所以我现在正试图学习如何在Obj-C中编码,我目前的目标是编写一个简单的命令行程序来计算矩形的面积和周长;然而,当我尝试这个程序时,Xcode总是向我抛出错误。 这是我的密码:

#import <Foundation/Foundation.h>

@interface Rectangle : NSObject {
@private
    int width;
    int height;
}

-(void) setWidth: (int) w;
-(void) setHeight: (int) h;
-(int)  width;
-(int)  height;
-(int)  area;
-(int)  perimeter;
@end

@implementation Rectangle

-(void) setWidth:(int)w
{
    width = w;
}
-(void) setHeight:(int)h
{
    height = h;
}
-(int) width
{
    return width;
}
-(int) height
{
    return height;
}
-(int) area  

你的代码绝对正确。这对我来说很有用。

单击“运行”按钮时有一个断点按钮。有时这会让你觉得代码不好,但它只是停在代码中的多个地方,代码是正确的,在xcode u中,在按钮上有一个小箭头和姿势按钮,点击左键,或者点击右上角写有“刹车点”的地方,然后按“播放”

你应该复制从编译器/gdb收到的整个错误消息,并粘贴到这里。我有几次遇到这个问题,xcode在某个“重影”处被破坏我在代码编辑器中看不到的断点,但是如果你点击cmd+alt+B并查看断点窗口,你可以从那里禁用或删除它们。它不是断点。你的程序崩溃了。看看调试器窗口,获取错误消息并粘贴到这里。嗯,我刚刚重新启动了计算机,现在它工作了。。奇怪的不管怎样,谢谢你。
{
    return height*width;
}
-(int) perimeter
{
    return 2 * width + 2 * height;
}
@end

int main (int argc, const char * argv []){
    @autoreleasepool {
        Rectangle * shape1 = [Rectangle new];

        [shape1 setHeight: 5];
        [shape1 setWidth: 15];

        NSLog(@"the area of the rectangle is %i and the perimeter is %i", [shape1 area],    [shape1 perimeter]);
    }
    return 0;
}