なぜこれがうまくいかないのかわかりません、私はそれをgoogledして何も見つかりませんでした。私はObj cとxcodeを初めて使っています。コードは、 - (void)setX:(int)xの前に何かを追加してもうまく動作しますが、それが自分自身にあるときはそうではありません...それは正常にビルドされますが、 "Thread 1:breakpoint 3.1"実装の行はsetXであった。これはなぜ動作しないのですか?
// Program to work with fractions – class version
#import <Foundation/Foundation.h>
//---- @interface section ----
@interface XYPoint: NSObject
-(void) setX: (int) x;
-(void) setY: (int) y;
-(int) getX;
-(int) getY;
@end
//---- @implementation section ----
@implementation XYPoint
{
int xpoint;
int ypoint;
}
-(void) setX: (int) x
{
xpoint = x;
}
-(void) setY: (int) y
{
ypoint = y;
}
-(int) getX
{
return xpoint;
}
-(int) getY
{
return ypoint;
}
@end
//---- program section ----
int main (int argc, char * argv[])
{
@autoreleasepool
{
XYPoint *point = [[XYPoint alloc] init];
[point setX: 4];
[point setY: 3];
NSLog(@"The points are: %i, %i", [point getX], [point getY]);
return 0;
}
}
これは動作しませんが、これはありません:ここに貼り付けることでフォーマットされるだろうと私は戻ってそれを置くとき、それは動作しますので...誰もい
// Program to work with fractions – class version
#import <Foundation/Foundation.h>
//---- @interface section ----
@interface XYPoint: NSObject
-(void) setX: (int) x;
-(void) setY: (int) y;
-(int) getX;
-(int) getY;
@end
//---- @implementation section ----
@implementation XYPoint
{
int xpoint;
int ypoint;
}
-(void) crap: (int) thing {}
-(void) setX: (int) x
{
xpoint = x;
}
-(void) setY: (int) y
{
ypoint = y;
}
-(int) getX
{
return xpoint;
}
-(int) getY
{
return ypoint;
}
@end
//---- program section ----
int main (int argc, char * argv[])
{
@autoreleasepool
{
XYPoint *point = [[XYPoint alloc] init];
[point setX: 4];
[point setY: 3];
NSLog(@"The points are: %i, %i", [point getX], [point getY]);
return 0;
}
}
[OK]をので、私はそれをインデント何が起こっているのか知っている?
+1この正解に基づいて、2番目のコード例が停止せずに実行される理由は、余分な空の関数が、ブレークポイントを 'setX: 'をブレークポイントから動かして行に落ちるということです。したがって、プログラムの実行は、ブレークポイントの行に決して行かない。 – NJones
これはもっと意味があります、このような迅速な対応に感謝します。 – GnarGnar