Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I freaking nailed it ! If you guys ever want to compose an email having the data from your UITableViewController here's how i made it. Just remember to import your data header file... </p> <pre><code>#import Recipe.h //in the implementation file #import Ingredients.h //in the implementation file #import &lt;MessageUI/MFMailComposeViewController.h&gt; // this line gotta be in the header file -(IBAction)sendmail{ MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init]; [composer setMailComposeDelegate:self]; NSString *recipeTitle = @"&lt;h5&gt;Recipe name: "; recipeTitle = [recipeTitle stringByAppendingFormat:recipe.name]; recipeTitle = [recipeTitle stringByAppendingFormat:@"&lt;/h5&gt;"]; NSString *ingredientAmount = @""; NSString *ingredientAisle = @""; NSString *ingredientTitle = @""; NSString *tableFirstLine = @"&lt;table width='300' border='1'&gt;&lt;tr&gt;&lt;td&gt;Ingredient&lt;/td&gt;&lt;td&gt;Amount&lt;/td&gt;&lt;td&gt;Aisle&lt;/td&gt;&lt;/tr&gt;"; NSString *increments = @""; increments = [increments stringByAppendingFormat:recipeTitle]; increments = [increments stringByAppendingFormat:tableFirstLine]; int i; for (i=0; i &lt; [ingredients count]; i++) { Ingredient *ingredient = [ingredients objectAtIndex:i]; ingredientTitle = ingredient.name; ingredientAmount = ingredient.amount; ingredientAisle = ingredient.aisle; increments = [increments stringByAppendingFormat:@"&lt;tr&gt;&lt;td&gt;"]; increments = [increments stringByAppendingFormat:ingredientTitle]; increments = [increments stringByAppendingFormat:@"&lt;/td&gt;&lt;td&gt;"]; increments = [increments stringByAppendingFormat:ingredientAmount]; increments = [increments stringByAppendingFormat:@"&lt;/td&gt;&lt;td&gt;"]; increments = [increments stringByAppendingFormat:ingredientAisle]; increments = [increments stringByAppendingFormat:@"&lt;/td&gt;&lt;/tr&gt;"]; if (i == [ingredients count]) { //IF THIS IS THE LAST INGREDIENT, CLOSE THE TABLE increments = [increments stringByAppendingFormat:@"&lt;/table&gt;"]; } } NSLog(@"CODE:: %@", increments); if ([MFMailComposeViewController canSendMail]) { [composer setToRecipients:[NSArray arrayWithObjects:@"123@abc.com", nil]]; [composer setSubject:@"subject here"]; [composer setMessageBody:increments isHTML:YES]; [composer setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; [self presentModalViewController:composer animated:YES]; [composer release]; }else { [composer release]; } } </code></pre> <p>This one was a huge step for me and it is actually very useful if you want to create interesting (basic) tools in your app. Thanks to everyone in this quintessential website for objective-c programmers.</p> <p>Andthis is the result you get. Simple but a good way to start.</p> <p><img src="https://i.stack.imgur.com/4XOSn.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload