2014-01-05 24 views
0

我有一個視圖,用戶可以翻閱其他用戶的配置文件。如果他們願意,用戶可以選擇通過電子郵件發送這些用戶。我遇到的問題只是正在使用的第一個配置文件的電子郵件。從解析表中獲取正確的電子郵件集

例如...

比方說,中有3個配置文件,每個人都有一個唯一的電子郵件。

[email protected]

[email protected]

[email protected]

只有[email protected]是越來越回升。

我應該將這些存儲在一個數組中,並將它們挑出來嗎?

或者是推薦的另一種方法?

編輯:

爲了澄清,我不想在一次電子郵件的每封電子郵件,他們需要是唯一的用戶正在觀看的輪廓。

因此,如果他們看着配置文件C,他們只需要發送電子郵件至[email protected]

這裏的東西我曾嘗試:

// Profile Generator Method 
- (void)createProfile 
{ 
    // I use a for loop to create each profile 
    // in the for loop I set the emails to the array, see below 
    [self.emailArray addObject:[self.profileObject objectForKey:@"email"]]; 

    // add the emailUser method as a target to a button 
} 

// My Email Method 
- (void)emailUser 
{ 
    for (int i = 0; i < [self.emailArray count]; i++) 
    { 
     self.emailString = [NSString stringWithFormat:@"%@", [self.emailArray objectAtIndex:i]]; 

     MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init]; 

     [mc setSubject:@"Note"]; 
     [mc setToRecipients:[NSArray arrayWithObject:self.emailString]]; 

     mc.mailComposeDelegate = self; 

     if([MFMailComposeViewController canSendMail]) 
     { 
      [self presentViewController:mc animated:YES completion:nil]; 
     } 
     else 
     { 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device is not configured to send mail." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
      [alert show]; 
     } 

    } 
} 

編輯兩個:

當我登錄我emailArray的輪廓正在創建我看到陣列中的所有電子郵件。

當我到達emailUser方法時,只出現一個。

+0

發佈您嘗試過的一些代碼 –

回答

0

如果你想發送幾封電子郵件,但單獨使用多個MFMailComposeViewController將不是好的選擇。 相反,您應該通過您自己的網絡服務發送這些電子郵件。將所有電子郵件地址傳遞給Web服務(PHPDotNet等),並且它應該爲每封電子郵件準備獨特的內容並單獨發送。

如果您不能使用網絡服務,那麼您應該在Queued模型中一個接一個呈現MFMailComposeViewController。重複呈現MFMailComposeViewController一個接一個是不好的用戶體驗。

+0

雖然這會將所有電子郵件加載到收件人字段中。他們需要匹配用戶目前正在查看的配置文件。 –

+0

你的意思是,電子郵件應該發送給所有人,但個人?每封電子郵件只應包含其收件人地址。 –

+0

對,如果你是在個人資料A上,只發送電子郵件的人,而不是每個配置文件的電子郵件。 –

相關問題