我一用NSLog输出汉字,就会报这个错误,请问我这个是什么原因,有的时候还会报那个 Codepoint out of range of the constant string,这是为什么,我用的Codeblock,请问我该怎么修改设置?
还有:我一个代码的结果为0,请大家帮我看看我哪里出错了,谢谢
#import <Foundation\Foundation.h>
#import <math.h>
@interface Point2D : NSObject
{
int _x;
int _y;
}
- (void)setX:(int)x;
- (void)setY:(int)y;
- (int)x;
- (int)y;
- (void)setX:(int)x andY:(int)y;
- (int)distanceWithOther:(Point2D *)other;
@end
@implementation Point2D
- (void)setX:(int)x
{
_x = x;
}
- (void)setY:(int)y
{
_y =y;
}
-(int)x
{
return _x;
}
-(int)y
{
return _y;
}
- (void)setX:(int)x andY:(int)y
{
[self x];
[self y];
}
- (int)distanceWithOther:(Point2D *)other
{
int a = [self x] - [other x];
int b = [self y] - [other y];
int c = pow( a,2);
int d = pow( b,2);
return sqrt(c+d);
}
@end
int main()
{
Point2D *p1 = [Point2D new];
[p1 setX:13 andY:25];
Point2D *p2 = [Point2D new];
[p2 setX:10 andY:21];
int a = [p1 distanceWithOther:p2];
NSLog(@"%d",a);
return 0;
} |