Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>to make a delegate you would add this above the interface declaration in <code>YourTwitterClass.h</code></p> <pre><code>@protocol YourTwitterDelegate &lt;NSObject&gt; -(void)delegteMethod; @end </code></pre> <p>You would do something like this by subclassing <code>NSObject</code> </p> <pre><code>//In YourTwitterClass.h //Twitter framework(needed but I don't know the name) #import &lt;Twitter/Twitter.h&gt; #import &lt;UIKit/UIKit.h&gt; @interface YourTwitterClass : NSObject @property (nonatomic) id&lt;YourTwitterDelegate&gt; delegate; -(void)shareOnTwitter:(NSString *)text withUrl:(NSURL *)url withImage:(UIImage *)image delegate:(id&lt;YourTwitterDelegate&gt;)del; @end //in YourTwitterClass.m @implementation YourTwitterClass -(void)shareOnTwitter:(NSString *)text withUrl:(NSURL *)url withImage:(UIImage *)image delegate:(id&lt;YourTwitterDelegate&gt;)del{ _delegate = del; [_delegate delegateMethod];//calls the delegate method //do twitter stuff } </code></pre> <p>and then in your view controller </p> <pre><code>//import "YourTwitterClass.h" - (IBAction)socialBtn:(id)sender { YourTwitterClass *t = [[YourTwitterClass alloc] init]; [t shareOnTwitter:@"This is Text" withUrl:nil withImage:nil]; } //and the delegate method -(void)delegateMethod{ NSLog(@"This is a delegate method!); } </code></pre> <p>In your <code>ViewController.h</code> file you also have to add this to the interface declaration</p> <p><strong>EDIT</strong> if you want to add a delegate for say, a mail composer, add the delegate for that class</p> <pre><code>@interface ViewController : UIViewController &lt;MFMailComposeViewControllerDelegate&gt; //or @interface YourTwitterClass : NSObject &lt;MFMailComposeViewControllerDelegate&gt; </code></pre>
    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. This table or related slice is empty.
    1. 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