从0开始学习OC程序-第13天
来源:互联网 发布:打预防针下载什么软件 编辑:程序博客网 时间:2024/06/04 19:34
Foundation 框架简单学习
//// main.m// Foundation学习//// Created by 北国 on 16/3/18.// Copyright © 2016年 beiguo. All rights reserved.//#import <Foundation/Foundation.h>int main(int argc, const char * argv[]) { @autoreleasepool { NSString *str = @"i love oc"; NSRange r = NSMakeRange(2, 4); NSRange nsr = [str rangeOfString:@"love"]; NSLog(@"location = %ld,length=%ld",nsr.location,nsr.length); NSPoint np = CGPointMake(10, 20); CGRect cr = CGRectMake(0, 0, 0, 0); NSString *st1 = @"123"; //C语言字符串转成OC字符串 NSString *st2 = [[NSString alloc] initWithUTF8String:"xxx"]; //OC字符串转成C语言字符串 char *cs = [st2 UTF8String]; //从字符串中读取然后显示给用户 NSString *st3 = [[NSString alloc]initWithContentsOfFile:@"/User/..." encoding:NSUTF8StringEncoding error:nil]; //NSString 为不可变字符串 //NSMutableString 可变字符串 NSMutableString * nus = [NSMutableString stringWithFormat:@"haha"]; [nus appendString:@"eee"]; NSLog(@"%@",nus); NSRange nr11 = [nus rangeOfString:@"ae"]; [nus deleteCharactersInRange:nr11]; NSLog(@"%@",nus); //NSArray 不可变 NSMutableArray 可变数组 NSArray *array = @[@"wwww",@"xxxx"]; for (id obj in array) { NSLog(@"array is %@",obj); } //NSSet 没有顺序的集合 NSSet *set = [NSSet set]; NSSet *set1 = [NSSet setWithObjects:@"xx",@"xxx",@"xxxx", nil]; NSString *stttt = [set1 anyObject]; NSLog(@"stttt is %@",stttt); //NSDictionary NSMutableDicionary NSDictionary *dict = @{@"name" : @"北国",@"address":@"黑龙江"}; id obj = dict[@"name"]; //字典遍历 NSArray *keys = [dict allKeys]; for (int i=0; i<dict.count; i++) { NSLog(@"key is %@, value is %@",keys[i],dict[keys[i]]); } NSLog(@"%@",obj); } return 0;}
0 0
- 从0开始学习OC程序-第13天
- 从0开始学习OC程序-第1天
- 从0开始学习OC程序-第2天
- 从0开始学习OC程序-第3天
- 从0开始学习OC程序-第4天
- 从0开始学习OC程序-第5天
- 从0开始学习OC程序-第6天
- 从0开始学习OC程序-第7天
- 从0开始学习OC程序-第8天
- 从0开始学习OC程序-第9天
- 从0开始学习OC程序-第10天
- 从0开始学习OC程序-第11天
- 从0开始学习OC程序-第12天
- 从0开始学习OC程序-第14天
- 从0开始学习SpringBoot-第1天
- 从0开始学习SpringBoot-第2天
- 从0开始学习SpringBoot-第3天
- 开始学OC【第8天】
- 怎么判断sql文件的编码格式
- ubuntu&redhat网络配置
- Codeforces 620E New Year Tree
- 线程和进程
- ubuntu设置开机启动图形应用程序,替换默认图形桌面
- 从0开始学习OC程序-第13天
- addChildViewController
- Hdu 5615 Jam's math problem【数学】
- 一道阿里笔试题-javascript
- 关于有偿提供拼图响应式后台的通知
- 推销员
- maven 的使用
- 自己创建storyboard
- 可可的OO:封装