|
Changed the code as follows :
// For sending mail
- (IBAction) sendMail: (id) sender
{
NSMutableString *url = [NSMutableString stringWithString: @"mailto:"];
NSString *str;
NSEnumerator *enumerator;
NSNumber *index;
// Check if there is a selected row
if ([tableView numberOfSelectedRows] == 0)
{
return;
}
// Enumerate all selected rows
enumerator = [tableView selectedRowEnumerator];
// Traverse the selected rows with enumerator
while ( ( index = [enumerator nextObject] ) )
{
// Retrieve the email field
str = [[records objectAtIndex: [index intValue]]
objectForKey: @"Email"];
// Add a comma to separate email addresses if this is not the first one
if (![url isEqualToString: @"mailto:"])
{
[url appendString: @","];
}
// Add the email address to the previously built string
[url appendString: str];
}
|