Hello,
The code below is written to fill a table with the values from an array. The array gets its values from a KML file.
- (void)loadView {
aTableView = [[UITableView alloc]initWithFrame:CGRectMake(20.0, 110.0, 150.0, 150.0)];
aTableView.delegate = self;
aTableView.dataSource = self;
aTableView.autoresizesSubviews = YES;
dataForMyTable = [[NSMutableArray alloc]init];
NSURL *url = [NSURL URLWithString
"http://aWebsite"];
XMLToObjectParser *myParser = [[XMLToObjectParser alloc] parseXMLAtURL:url toObject
"Placeholder" parseError:nil];
NSMutableArray *tempArray = [myParser items];
int i=0;
for(i=0; i<5; i++) {
[dataForMyTable insertObject:WHAT VALUE HERE atIndex:i];
}
self.view = aTableView;
}
If I use the following code with the string TEST a table with the values TEST is created.
for(i=0; i<5; i++) {
[dataForMyTable insertObject:@"TEST" atIndex:i];
}
The problem is that I would like to add the object on place i in the temp array, to the dataForMyTable array analogue to:
for(int i=0; i<someInt; i++)
dataForMyTable = tempArray;
I suppose aswell that I should cast the values in the tempArray to string in order to show them on the screen? How do I do that? Is there a method to loop through the array and cast every post to string and add the new value into a new array? Or how does it work in objective-c?
any hints for a newbee?
regards MACloop
The code below is written to fill a table with the values from an array. The array gets its values from a KML file.
- (void)loadView {
aTableView = [[UITableView alloc]initWithFrame:CGRectMake(20.0, 110.0, 150.0, 150.0)];
aTableView.delegate = self;
aTableView.dataSource = self;
aTableView.autoresizesSubviews = YES;
dataForMyTable = [[NSMutableArray alloc]init];
NSURL *url = [NSURL URLWithString
XMLToObjectParser *myParser = [[XMLToObjectParser alloc] parseXMLAtURL:url toObject
NSMutableArray *tempArray = [myParser items];
int i=0;
for(i=0; i<5; i++) {
[dataForMyTable insertObject:WHAT VALUE HERE atIndex:i];
}
self.view = aTableView;
}
If I use the following code with the string TEST a table with the values TEST is created.
for(i=0; i<5; i++) {
[dataForMyTable insertObject:@"TEST" atIndex:i];
}
The problem is that I would like to add the object on place i in the temp array, to the dataForMyTable array analogue to:
for(int i=0; i<someInt; i++)
dataForMyTable = tempArray;
I suppose aswell that I should cast the values in the tempArray to string in order to show them on the screen? How do I do that? Is there a method to loop through the array and cast every post to string and add the new value into a new array? Or how does it work in objective-c?
any hints for a newbee?
regards MACloop