Objective-C基础知识总结

NSRange

NSRange range = [self.displayLabel.text rangeOfString:@"."];
typedef struct _NSRange {
    NSUInteger location;
    NSUInteger length;
} NSRange;
如果字符串中未包含字符,那么range.location=NSNotFound


CGFloat

Just a floating point number, but we always use it for graphics.


CGPoint
C struct with two CGFloats in it: x and y. 

CGPoint p = CGPointMake(34.5, 22.0); p.x += 20; // move right by 20 points


CGSize
C struct with two CGFloats in it: width and height. 

CGSize s = CGSizeMake(100.0, 200.0);

s.height += 50; // make the size 50 points taller


CGRect
C struct with a CGPoint origin and a CGSize size.
CGRect aRect = CGRectMake(45.0, 75.5, 300, 500);
aRect.size.height += 45; // make the rectangle 45 points taller 

aRect.origin.x += 30; // move the rectangle to the right 30 points


Enumeration

 NSDictionary *myDictionary = ...;
   for (id key in myDictionary) {
// do something with key here
id value = [myDictionary objectForKey:key];
// do something with value here }


Think of @“string” as autoreleased




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值