Property 'tag' not found on object of type '_strong id'

I am building an App according to this tutorial (http://bit.ly/NI9kQe) which uses a custom web api to connect to the web server. One of the requirements is to detect whether or not the Login or Register button has been tapped. This is done using a “tag” which has been set for the button in interface builder (the register button has a tag of 1).

The chunk of code sits inside the btnLoginRegisterTapped method as follows (the error occurs on the line -> NSString* command = (sender.tag==1)?@”register”:@”login”;):

  • iOS app icon with transparent background showing black background on device
  • Calling topLayoutGuide breaks scrolling altogether?
  • What is the difference between NSInvocationOperation and NSBlockOperation
  • Force viewDidLoad to fire on iOS
  • UIImageView not updating with new image after picture taken or picture chosen from photo library
  • UIImageJPEGRepresentation returns nil
  • - (IBAction)btnLoginRegisterTapped:(id)sender {
    
    //form fields validation
    if (fldUserName.text.length < 4 || fldPassword.text.length < 4) {
      //  [UIAlertView error:@"Enter username and password over 4 chars each."];
    
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Opps!!" message:@"Enter  username and password over 4 chars each." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
        // optional - add more buttons:
        [alert addButtonWithTitle:@"Yes"];
        [alert show];
        return;
    
    }
    
    //salt the password
    NSString* saltedPassword = [NSString stringWithFormat:@"%@%@", fldPassword.text, kSalt];
    
    //prepare the hashed storage
    NSString* hashedPassword = nil;
    unsigned char hashedPasswordData[CC_SHA1_DIGEST_LENGTH];
    
    //hash the pass
    NSData *data = [saltedPassword dataUsingEncoding: NSUTF8StringEncoding];
    if (CC_SHA1([data bytes], [data length], hashedPasswordData)) {
        hashedPassword = [[NSString alloc] initWithBytes:hashedPasswordData length:sizeof(hashedPasswordData) encoding:NSASCIIStringEncoding];
    } else {
    
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Opps!!" message:@"Password cannot be reset!" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
        // optional - add more buttons:
        [alert addButtonWithTitle:@"Yes"];
        [alert show];
        return;
    }
    
    //************ THIS IS WHERE THE ERROR OCCURS *****************//
    //check whether it's a login or register 
    NSString* command = (sender.tag==1)?@"register":@"login";
    NSMutableDictionary* params =[NSMutableDictionary dictionaryWithObjectsAndKeys:
                                  command, @"command",
                                  fldUserName.text, @"username",
                                  hashedPassword, @"password",
                                  nil];
    
    //make the call to the web API
    [[API sharedInstance] commandWithParams:params
                               onCompletion:^(NSDictionary *json) {
                                   //handle the response
                                   //result returned
                                   NSDictionary* res = [[json objectForKey:@"result"] objectAtIndex:0];
    
                                   if ([json objectForKey:@"error"]==nil && [[res objectForKey:@"IdUser"] intValue]>0) {
                                       //success
                                       [[API sharedInstance] setUser: res];
                                       [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
    
                                       //show message to the user
                                       [[[UIAlertView alloc] initWithTitle:@"Logged in"
                                                                   message:[NSString stringWithFormat:@"Welcome %@",[res objectForKey:@"username"] ]
                                                                  delegate:nil
                                                         cancelButtonTitle:@"Close"
                                                         otherButtonTitles: nil] show];
    
                                   } else {
                                       //error
    
                                       UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Opps!!" message:@"Server down? Try Again" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
                                       // optional - add more buttons:
                                       [alert addButtonWithTitle:@"Yes"];
                                       [alert show];
                                       return;
    
                                   }
    
                               }];
    

    }

    when I try to build the project (workspace actually) I get the error:

    Property ‘tag’ not found on object of type ‘_strong id’

    I am using xcode 5.0 deploying for iOS7.

    Thanks,

    Solutions Collect From Internet About “Property 'tag' not found on object of type '_strong id'”

    Property syntax cannot be used with variables of the generic id type.

    So either replace sender.tag by the method call [sender tag] or better,
    use the actual type of the sender argument in the method definition:

    - (IBAction)btnLoginRegisterTapped:(UIButton *)sender { ... }
    

    Tip: When creating the action with “Control-Drag” in Xcode,
    use the pop-up in the “Type” field to select the actual type of the sender.
    Then the action method is created with the correct argument type.

    enter image description here