码迷,mamicode.com
首页 > 其他好文 > 详细

【Foundation Frame】Struct

时间:2014-12-04 20:02:22      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:foundation   object c   struct   nsrange   cgpoint   

//
//  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;
}

【Foundation Frame】Struct

标签:foundation   object c   struct   nsrange   cgpoint   

原文地址:http://blog.csdn.net/sinat_15735647/article/details/41728049

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!