转载自 http://blog.sina.com.cn/s/blog_7d1531ed0100v4eh.html
thanks for sharing
OC中只有四种简单数据类型
int、float、double和char
扩展类型:
long、long long、short、unsigned和signed
占位符:
1. short int
2. unsigned short int %hu %hx %ho
3. int
4. unsigned int %u %x %o
5. long int
6. unsigned long int
7. long long int
8. unsigned long long int
9. float %f %e %g %a
10. double
11. long double %Lf $Le %Lg
12. id %p
13. bool %d 0表真,1表假
//NSLog的格式如下,当然[NSString stringWithFormat:]的格式也是一样的。
//
%@
%zu
例子:
User.h
#import <Foundation/Foundation.h>
@interface User : NSObject
{
}
@property float ff; //标签方法实现set,get
@property double dd;
@property char cc;
-(void) setUid:(long)_uid;
-(long) uid;
-(void) setMyid:(long) _uid andUname:(NSString *) _uname andSex:(short int) _sex;
-(NSString *) uname;
-(short int) sex;
-(void) setMyInfo:(long)_uid:(NSString *)_uname:(short int)_sex;
-(float) suan;
@end
User.m
#import "User.h"
@implementation User
- (id)init
{
}
@synthesize ff; //标签方法实现set,get
@synthesize dd;
@synthesize cc;
-(void) setUid:(long)_uid
}
-(long) uid{
}
-(void) setMyid:(long) _uid andUname:(NSString *) _uname andSex:(short int) _sex{
}
-(NSString *) uname{
}
-(short int) sex{
}
-(void) setMyInfo:(long)_uid:(NSString *)_uname:(short int)_sex{
}
-(float) suan{
}
@end
对象的使用:
//
//
//
//