嗨,大家好,我得到根本不算什麼(零值),當我嘗試初始化我的NSXMLParser與我從Web服務響應中獲取數據,這是我使用的代碼:零的NSXMLParser初始化數據IOS
header.h
NSData*abccc;
NSMutableData*conWebMutableData;
NSXMLParser*xmlParser;
@interface ResponseWebServices_View : UIViewController<NSStreamDelegate, NSXMLParserDelegate>
@property(nonatomic,strong)NSMutableString*soapResults;
@property(nonatomic,strong)NSXMLParser*xmlParser;
@property(nonatomic, strong)NSData*abcc;
@end
file.m
-(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response{
[conWebMutableData setLength:0];
}
-(void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data{
[conWebMutableData appendData:data];
}
-(void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error{
NSLog(@"ERROR with con");
}
-(void)connectionDidFinishLoading:(NSURLConnection*)connection{
NSString*theXML = [[NSString alloc]initWithBytes: [conWebMutableData mutableBytes] length:[conWebMutableData length]encoding:NSUTF8StringEncoding];
NSLog(theXML);
abccc= [theXML dataUsingEncoding:NSUTF8StringEncoding];
//xmlParser = [[NSXMLParser alloc]initWithData:conWebMutableData]; (0x00000000)xmlParser value i get
//xmlParser = [[NSXMLParser alloc]initWithData:abccc]; (0x00000000)xmlParser value
[xmlParser setDelegate:self ];
[xmlParser setShouldResolveExternalEntities: YES];
[xmlParser parse];
}
// XMLPARSER = [[ALLOC的NSXMLParser] initWithData:conWebMutableData]; NSXMLParser分配評論在你的代碼請取消註釋,然後嘗試 – 2012-07-19 11:54:02
「conWebMutableData」需要是初始化/分配否則它不會保留服務器響應... – 2012-07-19 13:08:04