类型:
NSString
NSInteger
NSLong控制台输出
NSObject:对象
比较两个对象是否相等:
- NSObject *object1 = [[NSObject alloc] init];
- NSObject *object2 = obejct1;
- if([object isEqual:object2])
- {
- NSLong(@"is equal");
- }
- else
- {
- NSLong(@"is not equal");
- }
判断一个string是否为空:
- NSString *shortString = @"HelloWorld";
- if([shortString lengtg] == 0)
- {
- NSLong(@"is empty string");
- }
- else
- {
- NSLong(@"is not empty string ");
- }
循环结构,比如for:
- int increment = 0;
- for (increment = 0; increment < 100; increment++)
- {
- NSLog(increment++);
- }
-(void) method : (int) arguments;
-为方法类型 +表示类方法
-(id) initWithAge:(int) _age identify:(int)_identify
方法名称为initWithAge,第一个参数是(int) _age,第二个参数是(int)_identify
identify其实是对_identify的一个说明,initWithAge对_age一个说明
方法的调用:
1.[类名或对象名 方法名];
2.对象名.方法名
- NSString *s;
- s = [[NSString alloc] initWithString:@Hello iphone4S];
- Person *person = [Person alloc];
- person = [person init];
- -(id) initWithAge:(int)_age identify:(int) _identify
- {
- if<