Reputation: 2243
i have created an alertview with textfield and the details which is inserted in textfield have to be accessed when i select a button.here is my code
-(IBAction)addcart:(id)sender{
UIAlertView *customAlertView = [[UIAlertView alloc] initWithTitle:@"Enter Your quantity" message:@"" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:@"Cancel", nil];
txtfield = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 40.0, 260.0, 20.0)];
[txtfield setBackgroundColor:[UIColor whiteColor]];
[txtfield setKeyboardType:UIKeyboardTypeNumberPad];
[customAlertView addSubview:txtfield];
[customAlertView show];
[customAlertView release]; }
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
if (buttonIndex == 0)
{
NSString* str=txtfield.text;
qtystr=str;
}
-(IBAction)showcontent:(id)sender{
NSLog(@"%@",qtystr); }
here qtystr,txtfield i've created property and synthesized it..But i dont know where i'm missing it...
Upvotes: 0
Views: 324
Reputation: 31016
If qtystr
is a property, use self.qtystr
when you reference it.
(Otherwise, use a breakpoint on qtystr=str;
to see what the values are during the assignment.)
Upvotes: 1