Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use object of two class in each other in xcode?
    primarykey
    data
    text
    <p>I have two classes:</p> <ul> <li>ServiceProviderCompleteProfile </li> <li>RadioButton.</li> </ul> <p>By importing the <code>RadioButton</code> class in <code>ServiceProviderCompleteProfile</code> I can create radio button.</p> <p>I have declared all method related to radio button in it's own class.</p> <p>Now I want to enable a textbox in my <code>ServiceProviderCompleteProfile</code> instance when a <code>RadioButton</code> is selected. To achieve this, I am importing <code>ServiceProviderCompleteProfile</code> in <code>RadioButton</code> too. </p> <p>I have written the code below but <code>ServiceProviderCompleteProfile</code>s object is not responding.</p> <p><strong>Button Initialisation</strong></p> <pre><code>- (id)initWithFrame:(CGRect)frame andOptions:(NSArray *)options andColumns:(int)columns { self.radioButtons = [[NSMutableArray alloc] init]; if (self = [super initWithFrame:frame]) { // Initialization code int framex = 0; framex = frame.size.width / columns; int framey = 0; framey = frame.size.height / ([options count] / (columns)); int k = 0; for(int i = 0; i &lt; ([options count] / columns); i++) { for(int j = 0;j &lt; columns; j++) { int x = framex*0.20; int y = framey*0.20; UIButton *btTemp = [[UIButton alloc]initWithFrame:CGRectMake(framex*j+x, framey*i+y, framex/2+x, framey/2+y)]; [btTemp addTarget:self action:@selector(radioButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; btTemp.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [btTemp setImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal]; [btTemp setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; btTemp.titleLabel.font =[UIFont systemFontOfSize:11.f]; btTemp.titleLabel.numberOfLines=1; btTemp.titleLabel.lineBreakMode=NSLineBreakByWordWrapping; btTemp.titleLabel.textAlignment=NSTextAlignmentLeft; [btTemp setTitle:[options objectAtIndex:k] forState:UIControlStateNormal]; btTemp.tag=j+1; [self.radioButtons addObject:btTemp]; [self addSubview:btTemp]; k++; } } } return self; } </code></pre> <p><strong>Button Action</strong></p> <pre><code>-(IBAction) radioButtonClicked:(UIButton *) sender { for(int i = 0; i &lt; [self.radioButtons count]; i++) { [[self.radioButtons objectAtIndex:i] setImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal]; } genderButtonIndex=[sender tag]; [sender setImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateNormal]; ServiceProviderProfileViewController *svc=[[ServiceProviderProfileViewController alloc]init]; if([sender tag] == 3) { NSLog(@"%d",genderButtonIndex); svc.txtGratuity.text=@"h"; svc.txtGratuity.userInteractionEnabled=YES; } else { svc.txtGratuity.userInteractionEnabled=NO; } } </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.
 

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