开发者

How to show the value stored in an array in Objective-C

开发者 https://www.devze.com 2023-03-29 17:01 出处:网络
I have stored data in an array from XML Parsing. In the array I have stored latitude and longitude of the start and end point. Now I want to show the value of lat and long in the table view\'s cell.te

I have stored data in an array from XML Parsing. In the array I have stored latitude and longitude of the start and end point. Now I want to show the value of lat and long in the table view's cell.text. How can I access this? What syntax do I use so that I show the value of the element stored in the array? When I print to console it shows that the array has 12 objects. The values stored in the array are:

araystp= ( Step: 0x563f160, Step: 0x563f860, Step: 0x56400d0, Step: 0x56408e0, Ste开发者_JAVA技巧p: 0x56410f0, Step: 0x5641990, Step: 0x5642290, Step: 0x5642ae0, Step: 0x56434a0, Step: 0x5643e80, Step: 0x56446f0, Sleg: 0x5623850 )


suppose u have use array in XML file is listofPoint in which u have add your class's object.Now u synthesize a NSMutableArray in app delegate file. And where you are doing parsing event there after completion of parsing make copy of array listofPoint to appdelegate array. and in next class define object of class which you have add in listofPoint array. And use this syntax.

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

it will work.


Following is the code to get stored value from your xml calss.

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


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

精彩评论

暂无评论...
验证码 换一张
取 消