感到困惑的是如何解决这些错误(iOS)......有什么建议吗? [英] Baffled by what to do to fix these errors (iOS)...any suggestions?

查看:111
本文介绍了感到困惑的是如何解决这些错误(iOS)......有什么建议吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS开发人员的新手,并且使用一本书来学习。按照前面章节中的说明,我写了一个简短的应用程序(下面的代码)。它只需要一些文本输入并更改标签的文本以匹配它。但是,在模拟器中运行代码后,单击文本字段时出现以下错误:

I'm completely new to iOS dev and using a book to learn. Following the directions in one of the early chapters, I wrote a short app (code below). It just takes some text input and changes a label's text to match it. However, upon running the code in the simulator, I get the following error upon clicking into the textfield:


2012-06-08 11: 26:06.595 HelloNoun [14926:f803]打开'/ Users / clhu / Library / Application Support / iPhone Simulator / 5.1 / Library / Caches / com.apple.keyboards / images / 1859589221'失败:'没有这样的文件或目录'( 2)

2012-06-08 11:26:06.595 HelloNoun[14926:f803] Opening '/Users/clhu/Library/Application Support/iPhone Simulator/5.1/Library/Caches/com.apple.keyboards/images/1859589221' failed: 'No such file or directory' (2)

2012-06-08 11:26:06.702 HelloNoun [14926:f803]'插入存储值(?,​​?,?,?,?,? ,?,?)'约束失败(19)

2012-06-08 11:26:06.702 HelloNoun[14926:f803] 'INSERT INTO store VALUES (?,?,?,?,?,?,?,?)' constraint failed (19)

然后,当我按下按钮设置标签时,我收到这些错误以及:

then, when I press the button to set the label, I get these errors as well:


2012-06-08 11:27:09.050 HelloNoun [14926:f803] - [UIView text]:无法识别的选择器已发送到实例0xb75ac80

2012-06-08 11:27:09.050 HelloNoun[14926:f803] -[UIView text]: unrecognized selector sent to instance 0xb75ac80

2012-06-08 11:27:09.051 HelloNoun [14926:f803] * 由于未捕获的异常而终止应用程序'NSInvalidArgumentException ',原因:' - [UIView text]:无法识别的选择器发送到实例0xb75ac80

2012-06-08 11:27:09.051 HelloNoun[14926:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView text]: unrecognized selector sent to instance 0xb75ac80'

* 第一次抛出调用堆栈:

* First throw call stack:

(0x13c7022 0x1558cd6 0x13c8cbd 0x132ded0 0x132dcb2 0x21a7 0x13c8e99 0x1414e 0x140e6 0xbaade 0xbafa7 0xba266 0x393c0 0x395e6 0x1fdc4 0x13634 0x12b1ef5 0x139b195 0x12ffff2 0x12fe8da 0x12fdd84 0x12fdc9b 0x12b07d8 0x12b088a 0x11626 0x1dad 0x1d15)
终止称为抛出异常(lldb)

(0x13c7022 0x1558cd6 0x13c8cbd 0x132ded0 0x132dcb2 0x21a7 0x13c8e99 0x1414e 0x140e6 0xbaade 0xbafa7 0xba266 0x393c0 0x395e6 0x1fdc4 0x13634 0x12b1ef5 0x139b195 0x12ffff2 0x12fe8da 0x12fdd84 0x12fdc9b 0x12b07d8 0x12b088a 0x11626 0x1dad 0x1d15) terminate called throwing an exception(lldb)

我已经查看了我的连接并且现在已经多次回溯我的步骤并且没有看到任何明显的错误(尽管我对此非常新)。谁能帮助我指出正确的方向?谢谢!

I've looked over my connections and retraced my steps several times now and don't see anything blatantly wrong (although I am definitely very new to this). Could anyone help point me in the right direction? Thanks!

以下是代码:

// ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UILabel *userOutput;
@property (strong, nonatomic) IBOutlet UITextField *userInput;

- (IBAction)setOutput:(id)sender;

@end

// ViewController.m

#import "ViewController.h"

@implementation ViewController
@synthesize userOutput;
@synthesize userInput;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [self setUserOutput:nil];
    [self setUserInput:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (IBAction)setOutput:(id)sender 
{
    self.userOutput.text = self.userInput.text;
}
@end


推荐答案

我以前从未见过第一个错误,但您可以尝试删除路径 / Users / clhu / Library / Application Support / iPhone Simulator / 5.1 / Library / Caches 中的caches文件夹。模拟器应该足够聪明,可以重新创建它。

I have never seen the first error before but you could try deleting the caches folder at the path /Users/clhu/Library/Application Support/iPhone Simulator/5.1/Library/Caches. The simulator should be smart enough to recreate it.

对于第二个错误,我经常看到当我将属性连接到NIB中的错误视图时。看起来属性 userOutput 指向的是UIView而不是UITextField。您可以通过将以下行添加到
setOutput:来检查NIB中的连接或打印出userOutput的值。

For the second error, I usually see that when I connect a property to the wrong view in the NIB. It looks like the property userOutput is pointing at a UIView instead of a UITextField. You could check the connections in your NIB or print out the value of userOutput by adding the following line to setOutput:.

NSLog(@"%@", self.userOutput);

您日志中的输出应该类似于

The output in you log should look something like

< UITextField:0x6fea9f0; frame =(0 0; 100 31); clipsToBounds = YES; opaque = NO; layer =< CALayer:0x6fec700>>

这篇关于感到困惑的是如何解决这些错误(iOS)......有什么建议吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆