从应用delegate访问数组

在delegate中声明了一个数组:

@property(strong,nonatomic)NSMutableArray *books;

然后在XMLParser.m中给这个数组添加对象:

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName 
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {

    if([elementName isEqualToString:@"Books"])
        return;
    NSLog(@"i m in didEndElement");

    if([elementName isEqualToString:@"Book"]) {
        [appDelegate.books addObject:aBook]; //here i have added objects to array

        [aBook release];
        aBook = nil;

        NSLog(@"books=%@",appDelegate.books);
    }
    else 
        [aBook setValue:currentElementValue forKey:elementName];

    [currentElementValue release];
    currentElementValue = nil;
}

在XMLParser.h中声明数组:

@interface XMLParser : NSObject {
    NSMutableString *currentElementValue;

    AppDelegate *appDelegate;
    Book *aBook; 
}

现在需要访问在BooksDetailViewController.m中的数组,怎么实现?如何从应用delegate中访问数组?

使用如下代码会得到全局共享的AppDelegate

[[UIApplication sharedApplication] delegate]

你在向这个array里添加object的时候应该这么写

AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate.books addObject:aBook];

在BooksDetailViewController.m中读取时这么写

AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
id book = [appDelegate.books objectAtIndex:0];

但是我想问一下,你怎么把bookArray放到appDelegate这里呢...