title: Subject for custom UIActivity
body: <p>How do I specify that a custom <code>UIActivity</code> supports a subject?</p>
  
  <p>The documentation for the <a href="https://developer.apple.com/Library/ios/documentation/UIKit/Reference/UIActivityItemSource_protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIActivityItemSource/activityViewController:subjectForActivityType:" rel="nofollow">UIActivityItemSource</a> protocol mentions that you can implement the optional <code>activityViewController:subjectForActivityType:</code> selector, if you want you source to provide a subject:</p>
  
  <blockquote>
    <p>When posting an item the service may provide for a separate subject field and data field, such as an email message. Implement this method if you wish to provide a subject field for services that support one.</p>
  </blockquote>
  
  <p>But, as far as I can tell, it isn't documented anywhere how I might actually specify that my custom UIActivity supports a subject. How is this done?</p>
  
  <p><strong>Edit: To make my question clearer</strong></p>
  
  <p>Assume I have a custom activity item source, say <code>DocumentActivityItemSource</code> which implements the <code>UIActivityItemSource</code> protocol, and I have a custom <code>UIActivity</code>, which we can call <code>SendWithFooMessageActivity</code>.</p>
  
  <p>I then start a UIActivtyViewController:</p>
  
  <pre><code>NSArray *activityItems = @[[[DocumentActivityItemSource alloc] initWithDocument: document]];
  NSArray *applicationActivities = @[[[SendWithFooMessageActivity alloc] init]];
  UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems
                                                                                       applicationActivities:applicationActivities];
  [parentViewController presentViewController:activityViewController
                                     animated:YES
                                   completion:nil];
  </code></pre>
  
  <p>Now, in the popup I select the <code>SendWithFooMessageActivity</code>. The activity controller will then call <code>activityViewController:itemForActivityType:</code> on the <code>DocumentActivityItemSource</code> instance to get an item, which it will then forward to the <code>SendWithFooMessageActivity</code> by calling that objects <code>prepareWithActivityItems:</code> method.</p>
  
  <p>Normaly the activity item would be an image, a string or a url. In this case, let's say that the <code>DocumentActivityItemSource</code> returns a string with an exiting blurb about the document. The <code>SendWithFooMessageActivity</code> can then use this text as the body text of it's foo-mail message.</p>
  
  <p>However, a Foo message also requires a subject to be valid. Interestingly enough the <code>UIActivityItemSource</code> protocol also contains the optional <code>activityViewController:subjectForActivityType:</code> which is in fact documented to provide a subject to services that supports one.</p>
  
  <p>For the Apple provided email activity this does in fact happen - <code>activityViewController:subjectForActivityType:</code> is called on the <code>DocumentActivityItemSource</code> and the result is used in the email as subject.</p>
  
  <p>There does not seem to be, however, a way to specify that my custom <code>SendWithFooMessageActivity</code> would also like to get the subject from the activityitem? The documentation mentions that this happens for "services that supports [a subject]" - so then how do I specify that my service does in fact support one.</p>
  
  <p>Also, the same goes for the <code>activityViewController:thumbnailImageForActivityType:suggestedSize:</code>, which is supposed to provide a thumbnail to "services that supports one". This works for the default ShareOnTwitter and ShareOnFacebook activies, but there does not seem to be a way to get custom activites to support it. Is this possible?</p>
  
  <p>So far I have used the workaround that @chriszumberge is also providing below, which is to short-circuit the activityViewController and directly initialize the custom activity with the information it needs from the itemsource:</p>
  
  <pre><code>[SendWithFooMessageActivity alloc] initWithSubject: document.title];
  </code></pre>
  
  <p>But this does not seem to be the way that the whole <code>UIActivityViewController</code> setup is supposed to be used.</p>