原始数据类型与非原始数据类型(苹果定义的数据类型)之间有什么区别? [英] What is the difference between primitive data type vs an non primitive data type(apple defined data type)?

查看:294
本文介绍了原始数据类型与非原始数据类型(苹果定义的数据类型)之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两者之间的基本区别是什么?如果有人可以使用NSInteger和NSNumber的示例进行解释,那就太好了.谢谢

解决方案

主要区别在于它们在内存中的位置,对象存储在堆中,而值类型直接存储在堆栈中……

:是用于动态内存分配的内存区域.

堆栈:是为函数内的自动变量分配的内存部分.数据使用后进先出(LIFO)方法存储在堆栈中.

关于NSInteger和NSNumber:

NSInteger只是一个长整数的同义词,而NSNumber是一个Objective-C类,它是NSValue的特定子类.

What's the basic difference between the two..? it would be nice if can someone explain using the example of NSInteger and NSNumber.. Thanks

解决方案

The main difference is related to where they stay in the memory, objects are stored in the heap while value type are stored directly in the Stack ...

heap : is an area of memory used for dynamic memory allocation.

stack : is the section of memory that is allocated for automatic variables within functions. Data is stored in stack using the Last In First Out (LIFO) method.

About NSInteger and NSNumber :

NSInteger is nothing more than a synonym for a long integer, while NSNumber is an Objective-C class, a subclass of NSValue to be specific.

这篇关于原始数据类型与非原始数据类型(苹果定义的数据类型)之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆