iPhone应用程序具有“购物车”-如何将自定义对象转换为XML以发送到服务器

问题描述

|| 我的iPhone应用程序中有一个购物车。用户完成购物后,我想将购物车中的内容发送到服务器,PHP脚本在该服务器上处理输入。 在线研究之后,我发现可以将所有内容转换为XML文件,然后将其发送给服务器。 然后,我尝试在Apple的文档中找到如何执行此操作。在这里,我发现我只能将数组,字符串,数字,布尔值和字典等数据结构转换为XML文件或pList。 但是我的购物车中都有自定义对象和数组。我想转换为XML。 所以我想知道是否有人对我可以用来完成此任务的示例代码有任何建议或链接。 这是我的购物车的init方法的外观:
-(id)init
{
self = [super init];
if (sharedSingleton != nil ) 
   {
    NSLog(@\"inside init for Cart\");
    totalItemsInCart = 0;
    self.foodItemsArray = [[NSMutableArray alloc]initWithCapacity:0]; 
    self.drinkItemsArray = [[NSMutableArray alloc]initWithCapacity:0];       
    self.otherItemsArray = [[NSMutableArray alloc]initWithCapacity:0]; 
    selectedLocation = nil; //location object
    locationSelected = FALSE; //bool
    customerInfo = nil; //customer info model
    customerInfoObtained = FALSE; //bool
    self.numFoodItems = 0; //int
    self.gratuity = 0; //float
    self.miscCharges = 0; //float
    [self calculateTaxPercents];
   }

return sharedSingleton;
}
    

解决方法

        没有“调用方法”的方式来执行此操作。 要做的方法是找到一个可以创建和编辑xml的xml库。 快速搜索显示KissXML