macOS/iOS API解説

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

目次

propertyForKey:

キーでレシーバのプロパティを返します
-(id)propertyForKey:(NSString *)propertyKey:

解説

キーでレシーバのプロパティを返します。
なければnilを返します。
【propertyKey】
● NSHTTPPropertyStatusCodeKey ステータスのコード OKなら200番台、エラーなら400番台
● NSHTTPPropertyStatusReasonKey ステータスの文字 "OK"や"Not Found"など
● NSHTTPPropertyServerHTTPVersionKey HTTPバージョン
● NSHTTPPropertyRedirectionHeadersKey
● NSHTTPPropertyErrorPageDataKey エラーページデータ
この下は10.2以降
● NSHTTPPropertyHTTPProxy

返り値

( id )

オブジェクト

引数

( NSString * )propertyKey

キー

クラス

NSURL

Instance Methods

使用可能

10.0

参照

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
NSURL *url = [NSURL URLWithString:@"http://www.oomori.com/"];

NSLog( [[url propertyForKey:NSHTTPPropertyStatusCodeKey] 
description] );
NSLog( [[url propertyForKey:NSHTTPPropertyStatusReasonKey] 
description] );
NSLog( [[url propertyForKey:NSHTTPPropertyServerHTTPVersionKey] 
description] );
NSLog( [[url propertyForKey:NSHTTPPropertyRedirectionHeadersKey] 
description] );
NSLog( [[url propertyForKey:NSHTTPPropertyErrorPageDataKey] 
description] );

#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
NSLog( [[url propertyForKey:NSHTTPPropertyHTTPProxy] 
description] );
#endif

}

@end