Sorry,my company mac is English version,so I have to speak English in CSDN even though I'm Chinese.
Here is my code.A.h
#import <Cocoa/Cocoa.h>
@interface A : NSObject {
NSNumber* i;}
@property (retain) NSNumber* i;@end#import "A.h"
@implementation A
@synthesize i;-(void)dealloc{
[i release];
[super dealloc];
}#import <Foundation/Foundation.h>
#import "A.h"int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
A *a=[[A alloc] init];
NSNumber* i=[[NSNumber alloc] initWithInt:123];
[a setI:i];
NSLog(@"i is %d",[a i]);
[pool drain];
return 0;
}
I expected "i is 123" in console,but I only got "i is 109952".Why
Here is my code.A.h
#import <Cocoa/Cocoa.h>
@interface A : NSObject {
NSNumber* i;}
@property (retain) NSNumber* i;@end#import "A.h"
@implementation A
@synthesize i;-(void)dealloc{
[i release];
[super dealloc];
}#import <Foundation/Foundation.h>
#import "A.h"int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
A *a=[[A alloc] init];
NSNumber* i=[[NSNumber alloc] initWithInt:123];
[a setI:i];
NSLog(@"i is %d",[a i]);
[pool drain];
return 0;
}
I expected "i is 123" in console,but I only got "i is 109952".Why
解决方案 »
- ipad内存管理问题
- 伙计们,有哪些公司开发ipad网站啊?介绍下,老板要
- iphone的各位牛们帮忙给点意见!
- Mac10.9的环境,Xcode5上编译ffmpeg
- 怎么在已有的图片上增加新的图片按钮。。谢谢指教
- ios post传输dictionary到服务器端是否为json格式?
- 求助,分真心不多了,关于http异步请求接收到的数据 如何用这些数据来初始化view呢?
- 请教一个关于代码格式(排版)化的问题
- iOS tableview 右侧索引点击,显示提示
- 讯飞语音听写
- 有没有详细说明*.xcodeproj工程文件包里面具体每个文件的作用的文档?
- 在xcode下怎样通过wifi接收和发送数据,需要用到哪些库和哪些类?
对于所有的NSObject对象,都用%@输出:
NSLog(@"i is %@",[a i]);
或者你想用%d,那就将对用值转成int类型:
NSLog(@"i is %d",[a i].intValue);