2011-12-11 21 views
0
- (IBAction)doUpload:(id)sender 
{ 

    NSMutableArray *selected_items = [[NSMutableArray alloc] init]; 

    for (int i = 0; i<[appDelegate.notesArray count]; i++) { 
     if (selected[i]) [selected_items addObject:[appDelegate.notesArray objectAtIndex:i]]; 


      UploadView *uploadview = (UploadView *)self.view; 
      if (uploadview != nil) 
      { 

       [m_owner uploadString:here i want to pass the value]; 
       //[self dismissModalViewControllerAnimated:YES]; 
      } 


     }  
} 

在我的移動代碼,我想從UITableView中傳遞多個值[m_owner uploadString:在這裏,我要傳遞的值];但我只BLE字符串回教GDoc如何將mutbleArray轉換或分割爲Uplod字符串? 我DidSelecetRowAtIndexPathe代碼如下所示轉換MutbleArray到的NSString在iPhone的SDK

NSUInteger row = [indexPath row]; 

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
    if (cell.accessoryType == UITableViewCellAccessoryCheckmark) { 
     cell.accessoryType = UITableViewCellAccessoryNone; 
     selected[row] = NO; 
    } 
    else { 
     cell.accessoryType = UITableViewCellAccessoryCheckmark; 
     selected[row] = YES; 
    } 

    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
+0

我不明白這一點。請儘量使用更合適的英語。另外,你的目標是什麼?你想將一個NSMutableArray的元素連接成一個NSString? – 2011-12-11 14:56:13

回答

2

我不很瞭解你想要做什麼,但我認爲你需要的方法將一個數組的元素加入到一個字符串,用逗號或分居任何你想要的。

NSString *uploadString = [[array valueForKey:@"description"] componentsJoinedByString:@","]; 

方法的NSArray的description(如documented here)返回表示數組的內容,格式爲屬性列表,所以也沒用你的目的(其實它插入新行和外括號)的字符串。

+0

只有當數組itslef可以序列化到屬性列表中時,也就是說,它的所有元素都是有效的屬性列表對象(NSArray/NSDictionary,NSNstring,NSNumber,NSDate)。 – 2011-12-11 15:01:14

+1

有用的信息,謝謝你。 – Sylter