ios - how can i save the name of UIButton in string? -
i have button named
uibutton *button1;
how can save 'button1' in string? or able save or not?
check
import
#import "objc/runtime.h" -(ibaction)btnitemlistclicked:(id)sender { uibutton *btn=sender; nsstring *name = nil; uint32_t ivarcount; ivar *ivars = class_copyivarlist([self class], &ivarcount); if(ivars) { for(uint32_t i=0; i<ivarcount; i++) { ivar ivar = ivars[i]; id pointer = object_getivar(self, ivar); if(pointer == sender) { name = [nsstring stringwithutf8string:ivar_getname(ivar)]; break; } } free(ivars); } nslog(@"%@", name); }
output is:
printing description of name:
btnconferencecall
check sample demo
Comments
Post a Comment