objective-c 中数据类型之六 数值类(NSValue)
2016-01-12 11:51
666 查看
// NSValue能够将c类型转换为Objective-C对象,如NSRange,CGPoint。CGSize,CGRect,CGVector,UIEdgeInsets,UIOffset NSRange range = NSMakeRange(0, 1); NSValue *rangeValue = [NSValue valueWithRange:range]; // NSValue转换NSRange NSRange valueToRange = [rangeValue rangeValue]; // 自己定义的结构体 typedef struct {char *name; float score;} Student; Student studentA = {"xiao ming", 85.0}; NSValue *studentValue = [NSValue value:&studentA withObjCType:@encode(Student)]; // NSValue转换Student Student valueToStudent ; [studentValue getValue:&valueToStudent];
相关文章推荐
- iOS EnumerateObjectsUsingBlock和for-in对比
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- 面向对象(方法详解)
- Java - Get object size
- 简单讲解Objective-C的基本特性及其内存管理方式
- 013: class and objects > 简单继承
- 【Objective-C学习记录】第四十天
- 012: class and class objects > 初步了解
- R-CNN(Rich feature hierarchies for accurate object detection and semantic segmentation)
- error C2220 warning treated as error no object file generated
- Media foundation——Media source:Media source object module
- Objective-C错误模型
- iOS开发系列--Objective-C之KVC、KVO
- 项目中遇到的问题___不定时更新
- OBJECT ARX 获取标注样式信息
- 华为笔试(3)(有CObject内容)
- NSDictionary&& NSMutableDictionary使用
- CocoaPods一个Objective-C第三方库的管理利器
- OBJECT ARX 添加标注样式
- 系统自带JSonObject解析