<bdo id='Hbo6H'></bdo><ul id='Hbo6H'></ul>
  • <i id='Hbo6H'><tr id='Hbo6H'><dt id='Hbo6H'><q id='Hbo6H'><span id='Hbo6H'><b id='Hbo6H'><form id='Hbo6H'><ins id='Hbo6H'></ins><ul id='Hbo6H'></ul><sub id='Hbo6H'></sub></form><legend id='Hbo6H'></legend><bdo id='Hbo6H'><pre id='Hbo6H'><center id='Hbo6H'></center></pre></bdo></b><th id='Hbo6H'></th></span></q></dt></tr></i><div id='Hbo6H'><tfoot id='Hbo6H'></tfoot><dl id='Hbo6H'><fieldset id='Hbo6H'></fieldset></dl></div>

      <tfoot id='Hbo6H'></tfoot>
    1. <legend id='Hbo6H'><style id='Hbo6H'><dir id='Hbo6H'><q id='Hbo6H'></q></dir></style></legend>

    2. <small id='Hbo6H'></small><noframes id='Hbo6H'>

      1. 在“_strong id"类型的对象上找不到属性“标签"

        时间:2023-09-10
          <tbody id='PHFxF'></tbody>

        • <small id='PHFxF'></small><noframes id='PHFxF'>

          • <bdo id='PHFxF'></bdo><ul id='PHFxF'></ul>

            <legend id='PHFxF'><style id='PHFxF'><dir id='PHFxF'><q id='PHFxF'></q></dir></style></legend>
            1. <tfoot id='PHFxF'></tfoot>
              <i id='PHFxF'><tr id='PHFxF'><dt id='PHFxF'><q id='PHFxF'><span id='PHFxF'><b id='PHFxF'><form id='PHFxF'><ins id='PHFxF'></ins><ul id='PHFxF'></ul><sub id='PHFxF'></sub></form><legend id='PHFxF'></legend><bdo id='PHFxF'><pre id='PHFxF'><center id='PHFxF'></center></pre></bdo></b><th id='PHFxF'></th></span></q></dt></tr></i><div id='PHFxF'><tfoot id='PHFxF'></tfoot><dl id='PHFxF'><fieldset id='PHFxF'></fieldset></dl></div>

                • 本文介绍了在“_strong id"类型的对象上找不到属性“标签"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在根据本教程 (http://bit.ly/NI9kQe) 构建一个使用自定义 Web api 的应用程序连接到网络服务器.要求之一是检测是否已点击登录或注册按钮.这是使用为界面生成器中的按钮设置的标签"完成的(注册按钮的标签为 1).

                  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).

                  代码块位于 btnLoginRegisterTapped 方法中,如下所示(错误发生在行 -> NSString* command = (sender.tag==1)?@"register":@"login";):

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

                  - (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:

                  在_strong id"类型的对象上找不到属性标签"

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

                  我正在使用为 iOS7 部署的 xcode 5.0.

                  I am using xcode 5.0 deploying for iOS7.

                  谢谢,

                  推荐答案

                  属性语法不能用于泛型 id 类型的变量.

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

                  所以要么用方法调用[sender tag]替换sender.tag,要么更好,在方法定义中使用 sender 参数的实际类型:

                  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 { ... }
                  

                  提示: 在 Xcode 中使用Control-Drag"创建动作时,使用类型"字段中的弹出窗口来选择发件人的实际类型.然后使用正确的参数类型创建操作方法.

                  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.

                  这篇关于在“_strong id"类型的对象上找不到属性“标签"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将整数标签设置为 xml 布局文件中的小部件? 下一篇:扫描 NFC 标签时是否可以启动应用程序?

                  相关文章

                  <legend id='UIhNp'><style id='UIhNp'><dir id='UIhNp'><q id='UIhNp'></q></dir></style></legend>
                • <tfoot id='UIhNp'></tfoot>

                  <small id='UIhNp'></small><noframes id='UIhNp'>

                        <bdo id='UIhNp'></bdo><ul id='UIhNp'></ul>
                    1. <i id='UIhNp'><tr id='UIhNp'><dt id='UIhNp'><q id='UIhNp'><span id='UIhNp'><b id='UIhNp'><form id='UIhNp'><ins id='UIhNp'></ins><ul id='UIhNp'></ul><sub id='UIhNp'></sub></form><legend id='UIhNp'></legend><bdo id='UIhNp'><pre id='UIhNp'><center id='UIhNp'></center></pre></bdo></b><th id='UIhNp'></th></span></q></dt></tr></i><div id='UIhNp'><tfoot id='UIhNp'></tfoot><dl id='UIhNp'><fieldset id='UIhNp'></fieldset></dl></div>