07-21-2023, 10:18 PM
I am using addTarget:action:forControlEvents like this:
<pre><code>[newsButton addTarget:self
action:@selector(switchToNewsDetails)
forControlEvents:UIControlEventTouchUpInside];
</pre></code>
and I would like to pass parameters to my selector "switchToNewsDetails".
The only thing I succeed in doing is to pass the (id)sender by writing:
<pre><code>action:@selector(switchToNewsDetails:)</pre></code>
But I am trying to pass variables like integer values. Writing it this way doesn't work :
<pre><code>int i = 0;
[newsButton addTarget:self
action:@selector(switchToNewsDetails:i)
forControlEvents:UIControlEventTouchUpInside];
</pre></code>
Writing it this way does not work either:
<pre><code>int i = 0;
[newsButton addTarget:self
action:@selector(switchToNewsDetails:i:)
forControlEvents:UIControlEventTouchUpInside];
</pre></code>
Any help would be appreciated :)
<pre><code>[newsButton addTarget:self
action:@selector(switchToNewsDetails)
forControlEvents:UIControlEventTouchUpInside];
</pre></code>
and I would like to pass parameters to my selector "switchToNewsDetails".
The only thing I succeed in doing is to pass the (id)sender by writing:
<pre><code>action:@selector(switchToNewsDetails:)</pre></code>
But I am trying to pass variables like integer values. Writing it this way doesn't work :
<pre><code>int i = 0;
[newsButton addTarget:self
action:@selector(switchToNewsDetails:i)
forControlEvents:UIControlEventTouchUpInside];
</pre></code>
Writing it this way does not work either:
<pre><code>int i = 0;
[newsButton addTarget:self
action:@selector(switchToNewsDetails:i:)
forControlEvents:UIControlEventTouchUpInside];
</pre></code>
Any help would be appreciated :)