首页 > 代码库 > 【Foundation Frame】Struct

【Foundation Frame】Struct

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

#import<Foundation/Foundation.h>

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

#pragma结构体---------------
voidstructType()
{
   
//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 = [strrangeOfString:@"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;
 
}


intmain(intargc, const char * argv[]) {
   
@autoreleasepool {
       
       
structType();
    }
   
return 0;
}

【Foundation Frame】Struct