Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing argument 4 of 'obj_setProperty' from incompatible pointer type
    primarykey
    data
    text
    <p>I am getting the above compiler error in XCode, and I cannot work out what's going on.</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; // #import "HeaderPanelViewController.h" #import "HTTPClientCommunicator.h" #import "WebSocket.h" @class HeaderPanelViewController; @protocol ServerDateTimeUpdating -(void)serverDateTimeHasBeenUpdatedWithDate:(NSString *) dateString andTime:(NSString *) timeString; @end @interface SmartWardPTAppDelegate : NSObject &lt;UIApplicationDelegate, WebSocketDelegate&gt; { } @property (nonatomic, retain) id&lt;ServerDateTimeUpdating&gt; *serverDateTimeDelegate; .... @end </code></pre> <p>Then in this line</p> <pre><code>@synthesize serverDateTimeDelegate; </code></pre> <p>in ApplicationDelegate.m I am getting the error "Passing argument 4 of 'obj_setProperty' from incompatible pointer type". I did a bit of research and found that 'retain' only works on class types, which is fair enough. If I actually remove the 'retain' from the line</p> <pre><code>@property (nonatomic, retain) id&lt;ServerDateTimeUpdating&gt; *serverDateTimeDelegate; </code></pre> <p>it does compile without complaints. However, I think, that's the wrong thing to do. Surely my 'id' <em>is</em> a class type and surely it <em>should</em> be retained in the setter. BTW, here is the declaration of my HeaderPanelViewController which implements the aforementioned protocol:</p> <pre><code> @interface HeaderPanelViewController : UIViewController&lt;ServerDateTimeUpdating&gt; { } ... @end </code></pre> <p>Also, if I actually <em>do</em> remove the retain I get a problem later down the track when I actually call the setter to register my HeaderPanelViewController as the delegate:</p> <pre><code>// Register this instance as the delegate for ServerDateTimeUpdating // Retrieve the ApplicationDelegate... ApplicationDelegate *applicationDelegate = (ApplicationDelegate *) [UIApplication sharedApplication].delegate; // ...and register this instance applicationDelegate.serverDateTimeDelegate = self; </code></pre> <p>The last line causes the XCode error message "Passing argument 1 of 'setServerDateTimeDelegate' from incompatible pointer type".</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. This table or related slice is empty.
    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