开发者

Adding composer text box value to an array?

开发者 https://www.devze.com 2023-02-08 18:28 出处:网络
I have the coredata showing in text fields the data stored in view didload: tfEmail.text = editEmp.email;
  1. I have the coredata showing in text fields the data stored

    in view didload: tfEmail.text = editEmp.email;
    
  2. the message composer works as well, but if I want to use the email data to include in my message, I get the trouble...

    NSArray *toRecipients = [NSArray arrayWithObject:@"employee@example.com"];
    [picker setToRecipients:toRecipients];
    
  3. what I need to do is to include the tfEmail in the NSArray, so if I try

    NSArray *toRecipients = [NSArray arrayWithObject:@"%@", tfEmail.text];
    

    I will get an error

    Too many arguments to function arrayWithObje开发者_运维问答ct
    

How do I fix this?


You are tryig to pass a string to the array initializer but are actually passing in two strings. This line should be changed:

 NSArray *toRecipients = [NSArray arrayWithObject:@"%@", tfEmail.text];

You are passing in two string objects, @"%@" and tfEmail.text. Try removing the format string, like so:

NSArray *toRecipients = [NSArray arrayWithObject:tfEmail.text];

If you wanted to keep the format, wrap those strings as follows:

NSArray *toRecipients = [NSArray arrayWithObject:[NSString stringWithFormat:@"%@", tfEmail.text]];
0

精彩评论

暂无评论...
验证码 换一张
取 消