データをxml形式でiPhoneに送信しようとしています。しかし、配列を適切に機能させることができません。NSLog は null を返し続けます。これを修正するにはどうすればよいですか?
<?php
...(mysql query)
$q = $dbh->prepare( $sql );
$doc = new DOMDocument();
$r = $doc->createElement( "oneam" );
$doc->appendChild( $r );
foreach ( $q->fetchAll() as $row) {
$e = $doc->createElement( "location" );
$e->setAttribute( 'its', $row['oneam']);
$r->appendChild( $e );
}
print $doc->saveXML();
?>
ビューコントローラー用の私のXcode
- (void)viewDidLoad
{
[super viewDidLoad];
char *cStr = "YES";
NSString *str3 = [NSString stringWithUTF8String:cStr];
NSString *urlString = [NSString stringWithFormat:@"(censored)", _login];
NSXMLParser *Parser = [[[NSXMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]] autorelease];
[Parser setDelegate:self];
[Parser parse];
if (([[oneam objectForIndex:@"its" ]isEqualToString:@"YES" ])) {
[switch1 setOn:YES animated:YES];
}
else {
[switch1 setOn:NO animated:YES];
}
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
if ( [elementName isEqualToString:@"location"]) {
[oneam addObject:[[NSDictionary alloc] initWithDictionary:attributeDict]];
NSLog(@"The array is %@", oneam);
}
}