macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

valueWithPointer:

ポインタを含むNSValueオブジェクトを作って、返します
+(NSValue *)valueWithPointer:(const void *)aPointer:

解説

ポインタ(aPointer)を含むNSValueオブジェクトを作って、返します。
このメソッドはaPointerの内容をコピーしないので、NSValueオブジェクトが存在する間、そのメモリの割当てを絶対に解除しないようにしなければいけません。
ポインタを格納するオブジェクトはNSDataの方が適しているかもしれません。

返り値

( NSValue * )

バリュー

引数

( const void * )aPointer

ポインタ

クラス

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