首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么文本框代码不适用于Xcode 8 Obj-C?

为什么文本框代码不适用于Xcode 8 Obj-C?
EN

Stack Overflow用户
提问于 2017-04-15 00:39:47
回答 1查看 357关注 0票数 0

ViewController.h

代码语言:javascript
复制
@interface ViewController : UIViewController{

IBOutlet UITextField *Signup;
IBOutlet UITextField *Login;

}
@property(nonatomic, retain)IBOutlet UITextField *Signup;
@property(nonatomic, retain)IBOutlet UITextField *Login;

-(IBAction)TYPE:(id)sender;

ViewController.m

代码语言:javascript
复制
@synthesize Signup;
@synthesize Login;

-(IBAction)TYPE:(id)sender{
[Signup resignFirstResponder];
[Login resignFirstResponder];
}

在模拟器中,当我单击textfield时,会得到以下错误消息:

2017-04-14 18:43:52.616362 Prototype13075 13075:119579用于systemgroup.com.apple.configurationprofiles路径的系统组容器是systemgroup.com.apple.configurationprofiles 2017-04-14 18:43:52.640402 Prototype13075 13075:119579从私有有效用户设置读取。2017-04-14 18:43:52.727 Prototype13075 13075:119579找不到支持键盘iPhone-PortraitChoco-NumberPad类型4的键盘;使用1316927560_PortraitChoco_iPhone-Simple-Pad_Default 2017-04-14 18:43:53.607676 Prototype13075 13075:119579 _BSMachError:端口7403;(os/kern)无效能力(0x14)“无法插入COPY_SEND”2017-04-14 18:43:53.608246 Prototype13075 13075:119579 _BSMachError:端口7403;(os/kern)无效名称(0xf)“无法发送正确发送”

我已经两年没有使用Xcode了,但是同样的代码工作得很好,为什么Xcode 8,iOS 10不能工作呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-15 00:47:11

Xcode 8的模拟器非常冗长。这些信息并不意味着什么特别的。

- BTW --

您的代码是以一种非常旧的风格编写的,这已经不是最佳实践了。更好的办法是:

代码语言:javascript
复制
@interface ViewController : UIViewController
// It's no longer necessary to have your properties between { and }

@property (nonatomic, weak) IBOutlet UITextField *signup;
@property (nonatomic, weak) IBOutlet UITextField *login;
// IBOutlets should be weak, other properties should be weak or strong for objects, or assign for structs and values.
@end


@implementation ViewController

// You don't have to synthesize your properties anymore.

- (IBAction)type:(id)sender {
    [self.signup resignFirstResponder];
    [_login resignFirstResponder];
    // but you do have to either use self. or underscore to refer to them.
}

@end
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43420966

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档