释放时 NSValue 是否释放其值? [英] Does NSValue free its value when freed?
本文介绍了释放时 NSValue 是否释放其值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
看看这个伪代码:
void* magicpointer = malloc(OVER_NINE_THOUSAND);
NSValue* v = [NSValue valueWithPointer:magicpointer];
[v release];
当 v 被释放时,magicpointer 是否也被释放,还是我必须手动执行?我正在使用手动引用计数.
When v is released, does magicpointer get freed as well, or do I have to do that manually? I am using manual reference counting.
推荐答案
它不会被释放 - NSValue 只是一个包装器,因此您可以将任意值视为对象.它对包装的指针没有任何作用.
It doesn't get freed - NSValue is just a wrapper so you can treat arbitrary values as objects. It doesn't do anything with the wrapped pointer.
这篇关于释放时 NSValue 是否释放其值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文