如何从Web服务加载数组?

时间:2013-05-30 13:13:01

标签: ios objective-c nsarray

我有一个静态数组。这是静态数组。我想从Web服务加载。 例如

 - (void)viewDidLoad
 {
   [super viewDidLoad];

      tableData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto",
             @"Pig spit-roast", @"goat", @"beefed up beef", @"squidles",
             @"whale", @"crabbies", @"quack", @"Instant Noodle with Egg",
             @"Noodle with BBQ Pork", @"Japanese Noodle with Pork",
             @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake",
             @"Ham and Cheese Panini", nil];

         }

我想从服务中加载所有食物

     NSString *soapMessage =[NSString stringWithFormat:

      @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
 "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"    
      xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"   
      xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
"<soap:Body>"
"<List xmlns=\"http://tempuri.org/\">"
"<Foods></Foods>"

"</List>"
 "</soap:Body>"
"</soap:Envelope>"                            
];  

1 个答案:

答案 0 :(得分:2)

使用此XML解析库:TBXML

然后按照此逐步教程进行解析:xml-parsing-using-tbxml

希望它对你有所帮助。