macOS/iOS API解説

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

目次

childAtIndex:

指定した番号の子アイテムを返します
-(NSXMLNode *)childAtIndex:(unsigned int)index:

解説

指定した番号の子アイテムを返します。

返り値

( NSXMLNode * )

なし

引数

( unsigned int )index

クラス

NSXMLNode

Instance Methods

使用可能

10.4

参照

-childCount

例文

//ルートエレメントを作る
	NSXMLElement *root = 
		(NSXMLElement *)[NSXMLNode elementWithName:@"addresses"];
	//ルートからXMLドキュメントを作る
	NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithRootElement:root];
	
	[xmlDoc setVersion:@"1.0"];
	
	[xmlDoc setCharacterEncoding:@"UTF-8"];
	
	//ルート
	NSXMLNode *node1 = [NSXMLNode commentWithStringValue:@"1stchild"];
	NSXMLNode *node2 = [NSXMLNode commentWithStringValue:@"2ndchild"];
	
	[root addChild: node1 ];
	[root addChild: node2 ]; 
	
	NSLog(@"childAtIndex0: %@",[[node1 childAtIndex:0] description]);