我要求我要从单元格中选择多个值,我使用chekmark作为tableview的附件类型,如果用户多次选择tableview我想在数组中使用该值并在我的按钮单击中使用分享功能。这是我的多个选择配件类型的代码。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier;
CellIdentifier=[NSString stringWithFormat:@"cell %d",indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.detailTextLabel.numberOfLines = 0;
UIImageView* img = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bgCELL3@2X-1"]];
[cell setBackgroundView:img];
[img release];
count++;
}
NSMutableString *str=[[NSMutableString alloc]initWithString:[appDelegate.indexArray objectAtIndex:indexPath.section]];
cell.textLabel.text =str ;
cell.textLabel.font = [UIFont fontWithName:@"Georgia" size:14.0];
cell.textLabel.textColor = [UIColor brownColor];
NSMutableString *notes=[[NSMutableString alloc]initWithString:[appDelegate.notesArray objectAtIndex:indexPath.section]];
cell.detailTextLabel.text =notes;
cell.detailTextLabel.font = [UIFont fontWithName:@"Georgia" size:14.0];
cell.detailTextLabel.textColor = [UIColor darkGrayColor];
//textView.text=notes;
[notes release];
cell.backgroundColor=[UIColor clearColor];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSArray* toReload = [NSArray arrayWithObjects: indexPath, self.selectedIndexPath, nil];
self.selectedIndexPath = indexPath;
if ([[tableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryCheckmark){
BOOL selected = [[appDelegate.notesArray objectAtIndex:[indexPath row]] boolValue];
[appDelegate.notesArray replaceObjectAtIndex:[indexPath row] withObject:[NSNumber numberWithBool:!selected]];
[[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryNone];
}
else {
[[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryCheckmark];
}
}
我认为上面的代码是正确的,但我想与google doc共享多个值。但是GDoc的单值共享是成功的我希望得到多个选择值作为数组并通过按钮点击传递它.I尝试过但没有运气,这是我向GDoc分享笔记的代码
- (IBAction)doUpload:(id)sender
{
NSMutableArray *rowsToBeDeleted = [[NSMutableArray alloc] init];
NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
int index = 0;
for (NSNumber *rowSelected in appDelegate.notesArray)
{
if ([rowSelected boolValue])
{
[rowsToBeDeleted addObject:[appDelegate.notesArray objectAtIndex:index]];
NSUInteger pathSource[2] = {0, index};
NSIndexPath *path = [NSIndexPath indexPathWithIndexes:pathSource length:2];
[indexPaths addObject:path];
UploadView *uploadview = (UploadView *)self.view;
if (uploadview != nil)
{
[m_owner uploadString:path];
//[self dismissModalViewControllerAnimated:YES];
}
}
index++;
}
}
我收到"InComplatble pointer types sending NSIndexPath to parameter of type NSString"
的警告,但我将NSIndexpath更改为NSString like this NSString *path = [NSString indexPathWithIndexes:pathSource length:2];
而不是NSIndexPath *path = [NSIndexPath indexPathWithIndexes:pathSource length:2];
,但没有运气。
我在上面的代码中犯了什么错误?