【Foundation Frame】Struct

//
//  main.m
//  struct
//
//  Created by mac on 14-12-2.
//  Copyright (c) 2014 mac. All rights reserved.
//

#import <Foundation/Foundation.h>

#pragma mark 基本数据类型----
void baseType()
{
   
//unsigned long  %lu
   
NSUInteger i;
   
//long
   
NSInteger  j;
   
//double
   
NSTimeInterval  k;
}

#pragma 结构体---------------
void structType()
{
   
//first type
   
NSRange range = {34,67};
   
NSLog(@"%lu,%lu",range.location,range.length);
   
//second type
   
NSRange range1 = {.location = 43, .length = 76};
   
NSLog(@"%lu,%lu",range1.location,range1.length);
   
//third type
   
NSRange range3 = NSMakeRange(456, 789);
   
NSLog(@"%lu,%lu",range3.location,range3.length);
   
   
//example
   
NSString *str =@"Hello,NSStruct";
   
NSRange range4 = [str rangeOfString:@"Hello"];
   
NSLog(@"%lu,%lu",range4.location,range4.length);
   
   
//point
   
NSPoint  point = NSMakePoint(0.0, 0.0) ;
   
//size
   
NSSize  size  = NSMakeSize(34.2, 123.1);
   
//rect
   
NSRect  rect  = NSMakeRect(0.0, 0.0, 234, 231);
   
   
//CG 开头的结构体
   
CGPoint point1 = CGPointMake(0.0, 0.0);
   
CGSize  size1  = CGSizeMake(34.2, 123.1);
   
CGRect  rect2  = CGRectMake(45.2, 34.2, 40, 60);
  
   
CGPoint point2 = CGPointZero;
   
CGSize  size2 = CGSizeZero;
   
CGRect  rect3 = CGRectZero;
 
}


int main(int argc, const char * argv[]) {
   
@autoreleasepool {
       
       
structType();
    }
   
return 0;
}
posted @ 2014-12-04 18:17  shujucn  阅读(118)  评论(0编辑  收藏  举报