在這個函數中,我通過一個名爲AFKissXMLRequestOperation的kiss xml函數獲得xml。但是因爲它是無效的,所以我不能訪問XMLDocument,除非我使用NSLog,但是當我需要訪問XML時這沒有用。所以,我嘗試將它設置爲自我的變量,以便在其他函數中訪問它。如果我在NSLog self.xmlDocument塊內部,它的工作原理。但是,當我NSLog它在調用NSLog(@「self!%@」,[self.xmlDocument XMLStringWithOptions:DDXMLNodePrettyPrint])中的塊之外時,它是NULL。那麼如何訪問self.XMLDocument?無法訪問自我?
-(id)xmlRequest:(NSString *)xmlurl
{
AFKissXMLRequestOperation* operation= [AFKissXMLRequestOperation XMLDocumentRequestOperationWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:xmlurl]] success:^(NSURLRequest *request, NSHTTPURLResponse *response, DDXMLDocument *XMLDocument) {
NSLog(@"kiss operation %@", [XMLDocument XMLStringWithOptions:DDXMLNodePrettyPrint]);
self.xmlDocument=XMLDocument;
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, DDXMLDocument *XMLDocument) {
NSLog(@"Failure!");
}];
[operation start];
NSLog(@"self!%@", [self.xmlDocument XMLStringWithOptions:DDXMLNodePrettyPrint]);
return self.xmlDocument;
}
你在哪裏登錄? – 2012-07-30 15:36:53