I am doing parsing on xml file and fetched data from xml file and store that in array and further to rows of UITableView. I want to remove the extra word at 5th index '\U2019' and want to merge word 'i' and 'm all alone' to one row f UITableView.
"WHERE DOES LOVE LIVE",
"TRANSFORMATION OF THE SELF",
"EMPATHY STRUCTURES",
"MORE QUESTIONS THAN ANSWERS",
I,
"\U2019",
"M ALL ALONE",
"THE WILL TO LIVE",
"THE GUILT OF SELF DENIAL",
HOPELESSNESS,
"SOCIAL WANNABIES",
"THE POWER OF HOPE"
bunch of code:
- (UITableViewCell *)tableView:(UITableView *)tableViewcellForRowAtIndexPath:
(NSIndexPath *)indexPath
{ static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithFrame:CGRectZero];
}
if(indexPath.row > 0)
{ cell.textLabel.text = [blogtitle objectAtIndex: indexPath.row];
}}`
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSMutableString *)string
{
NSString *newString = [string stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
// save the characters for the current item...
if ( [currentElement isEqualToString:@"title"])
{
if ([newString length] > 0)
{
// NSMutableString *base64String = [newString base64Encod开发者_如何学CedString];
[blogtitle addObject:newString];
}
NSLog(@"blogtiltlearray...%@",blogtitle);
}}`
It's easy to remove an object at a specific index. Try:
[blogtitle removeObjectAtIndex:index];
EDIT: You can call [tableView reloadData];
in order to remove the row, assuming you've already loaded the tableView BEFORE you manipulated the array.
You can merge 2 strings together via:
NSString * mergedString = [NSString stringWithFormat:@"%@%@", string1, string2];
and you can replace one object in an array with another via:
[blogtitle replaceObjectAtIndex:index withObject:mergedString];
Hope that helps!
You can use NSMutable array and the method of it named removeObjectAtIndex:
精彩评论