2011-08-20 30 views
0

我已經將數據存儲在XML解析的數組中。在數組中,我存儲了起點和終點的經度和緯度。現在我想在表格視圖的cell.text中顯示lat和long的值。我怎樣才能訪問這個?我使用什麼語法來顯示存儲在數組中的元素的值?當我打印到控制檯時,它顯示數組有12個對象。存儲在數組中的值是:如何顯示存儲在數組中的值Objective-C

araystp =( 步驟:0x563f160, 步驟:0x563f860, 步驟:0x56400d0, 步驟:0x56408e0, 步驟:0x56410f0, 步驟:0x5641990, 步驟: 0x5642290, 步驟:0x5642ae0, 步驟:0x56434a0, 步驟:0x5643e80, 步驟:0x56446f0, Sleg:0x5623850 )

+0

你有什麼樣的陣列?一個C數組或一個NSArray對象? – 2011-08-20 07:57:32

回答

1

假設u必須在XML文件中使用數組是listofPoint中,u有添加類的object.Nowü合成的NSMutableArray在應用程序委託文件。並且在解析完成後解析事件的地方將數組listofPoint拷貝到appdelegate數組中。並在下一個類中定義您在listofPoint數組中添加的類的對象。並使用此語法。

yourclass * Object = [[yourclass alloc] init]; Object = [appDelegate.Array objectAtIndex:0]; NSLog(@「%f」,Object.var);

它會工作。

0
for (int i = 0 ; i <[array count];i++) 
{ 
YourXmlClass *x = [array objectAtIndex:i] 
NSString *s = x.latitude; 
NSString *s1 = x.longitude; 
    } 
1

以下是從xml calss中獲取存儲值的代碼。

for (int i = 0 ; i <[array count];i++) 
    { 
     XmlClass *class1 = (XmlClass*) [array objectAtIndex:i]; 
     NSString *strLat = class1.latitude; 
     NSString *strLong = class1.longitude; 
    }