valueWithPointer:
ポインタを含むNSValueオブジェクトを作って、返します
+(NSValue *)valueWithPointer:(const void *)aPointer:
解説
ポインタ(aPointer)を含むNSValueオブジェクトを作って、返します。
このメソッドはaPointerの内容をコピーしないので、NSValueオブジェクトが存在する間、そのメモリの割当てを絶対に解除しないようにしなければいけません。
ポインタを格納するオブジェクトはNSDataの方が適しているかもしれません。
返り値
( NSValue * )
バリュー
引数
( const void * )aPointer
ポインタ
フレームワーク
Foundation
クラス
NSValue
Class Methods
使用可能
10.0
参照
- pointerValue
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { //単にポインタを渡す場合 NSString *anObject = @"Obj-C string"; NSValue *theValue = [NSValue valueWithPointer: &anObject ]; id theObj; [theValue getValue:&theObj]; NSLog(@"---%@",*theObj); } @end