Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
Hi all,
I created a timer that connect to a method that creates buttons.
Evrey time the methods is running it overriding the last button and create new one(but keeps the old one active on screen).
In C# when you want to point to an the obcject you click on it you'r writing
PHP:
this.bla bla;
there is parallel function in objective C/Cocoa Touch that mean the same as "THIS"?(maybe "SELF")?

Thanks !!
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
There is self but I suspect that's not what you're wanting. Do you want a pointer to the UI object that triggered the action?

Also, what is your experience level with Objective-C and Cocoa Touch programming? What have you done to educate yourself on the fundamentals?
 

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
There is self but I suspect that's not what you're wanting. Do you want a pointer to the UI object that triggered the action?

Also, what is your experience level with Objective-C and Cocoa Touch programming? What have you done to educate yourself on the fundamentals?

I started to program a month ago, but I think my level is pretty good.
I have already set a target method that increase points when you click on the object(UIbutton).
what i meant is that when you click the button, the method tell the APP that you clicked the currently button that already override and remove it from super view, actually it's what you said,
so I tried
PHP:
[Self RemoveFromSuperView]
but it changed the background to white,I think it has removed the UIVIEW.

Do you have any idea how to point to the currently button I click on it?
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Based on your other thread, I see you've learned how to use addTarget:action:forControlEvents:. So, when you have your action method set up like so:
Code:
- (void)action:(id)sender {
what do you think sender is?
 

Sykte

macrumors regular
Aug 26, 2010
223
0
PHP:
[Self RemoveFromSuperView]




Even if self was UIButton this would still fail. Check your case.


Do not rush your learning. This is the reason I ask if you understood the code.
 

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
I think sender could be used to verify identity of the object, but I am not sure if I understood.
I mean,i know what is the method behind sender but not sure if I understood is well
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
I think sender could be used to verify identity of the object, but I am not sure if I understood
Yeah, unfortunately, I don't think you are understanding it either. You don't appear to have a good enough grasp of the basic fundamentals of iPhone programming and Cocoa Touch. I would suggest you step back from the real coding for now and go (re)learn those before you continue with your app.
 

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
It's the only thing that missing in my APP ,anyway I will relearn the basic.
hmm,what I am trying to do is possible?
 

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
Oops. Sorry. Not sure why I typed that. What I meant to say was:
Yes, it is possible.

haaaaaaaaaaaaaaaaaaaaaaaa
I tried to write
PHP:
[ sender removeFromSuperview];

and it's works,because the function takes the ID of the button(every button has special attribute) and place the ID at the Sender argument,
so if I am turning to the Sender it's takes the attribute of the current button I clicked on it the remove the button from the view
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
...because the function takes the ID of the button(every button has special attribute) and place the ID at the Sender argument
Well, that's not how I would phrase it. sender is being set to a pointer to the object that triggered the action. You've just defined the method to accept the generic-type of id rather than a specific datatype, such as UIButton*.

But I'm glad you got your code working, through your own process of discovery.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.