适用于 iPhone 模拟器,但不适用于手机

发布于 2024-10-06 08:15:08 字数 590 浏览 2 评论 0原文

所以我有一个应用程序可以在模拟器上正常运行,但不能在实际设备上运行。

在运行时,它给了我以下错误:

2010-12-05 19:58:32.006 Sports[4668:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableView isEqualToString:]: unrecognized selector sent to instance 0x800800'

关于结构的一些信息:我有一个选项卡栏控制器,第一个视图是 UINavigationController。

其中的视图是 UITableView。可能相关也可能不相关的一件事是,如果我这样做 @synthesize tableView;在表格视图控制器中,表格在模拟器和手机上都保持空白(但不会崩溃)。

如果我把它拿出来,它会在模拟器上加载正确的数据,并在手机上崩溃。

委托/数据源应该链接到界面生成器中的哪里?我尝试将其链接到“视图”到“文件所有者”,并制作一个新的“ViewController”,但这些都不起作用。

So I have an app which runs fine on the simulator, but not on the actual device.

At runtime, it gives me the following error:

2010-12-05 19:58:32.006 Sports[4668:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableView isEqualToString:]: unrecognized selector sent to instance 0x800800'

A bit about the structure: I have a Tab Bar Controller, the first view being a UINavigationController.

The view in there is a UITableView. One thing that may or may not be related is that if I do @synthesize tableView; in the table view controller, the table stays blank on both simulator and phone (but does not crash).

If I take that out, it loads the correct data on the simulator, and crashes on the phone.

Where should delegate/dataSource be linked to in the Interface Builder? I tried linking it to "View" to "File's Owner", and making a new "ViewController" and none of those worked.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

离去的眼神 2024-10-13 08:15:08

delegatedataSource 都应该链接到 File's Owner,它是将表视图声明为 IBOutlet 的视图控制器类;这应该是拥有 nib 文件的同一个视图控制器。此外,该视图控制器应该实现 UITableViewDelegate 和 UITableViewDataSource 协议。

添加该 @synthesize 行(除非您子类化 UITableViewController,正如 grahamparks 在评论中指出的那样!)确保这些连接正确,最后,确保您已为表视图声明了一个 IBOutlet,并在类和界面生成器之间正确连接了它。

Both the delegate and dataSource should be linked to File's Owner, which is the view controller class that declares the table view as an IBOutlet; this should be the same view controller that owns the nib file. Additionally, that view controller should be implement the UITableViewDelegate and UITableViewDataSource protocols.

Add that @synthesize line back in, (unless you're subclassing UITableViewController, as pointed out by grahamparks in the comments!) make sure those connections are right, and, finally, make sure you've declared an IBOutlet for the table view, and connected that properly between your class and interface builder.

淡水深流 2024-10-13 08:15:08

找到了!

事实证明这根本没有问题。问题是我的数据库中的日期字段在我的手机上运行时始终为零/零。

为什么?因为创建的 NSDate 对象从未初始化并保持为零。

为什么?

因为我的手机是24小时制的,没有正确解析上午和下午。

吸取教训!

Found it!

Turns out that there wasn't really a problem with this at all. The problem was that the date field in my database, when run on my phone was always zero/nil.

Why? Because the NSDate object created never initialized and stayed at nil.

Why?

Because my phone is in 24 hour time and did not parse the am and pm properly.

Lessons learned!

折戟 2024-10-13 08:15:08

将 NSZombieEnabled 设置为 yes 运行您的应用程序。有关说明,请参阅 http://www.cocoadev.com/index.pl?NSZombieEnabled关于它以及如何设置它。我想您会发现应用程序现在会在模拟器中抛出异常,告诉您正在向已释放的对象发送消息。

根据您收到的错误消息,我预计罪魁祸首是 NSString 或 NSMutableString 对象。如果它是一个 NSString 则警告,该 NSString 可能被多个不同的对象共享,因此弄清楚额外的释放在哪里可能很困难。

不过不用担心,Instruments 在这方面提供了巨大的帮助。这里有一个链接,解释了如何使用 Instruments 来准确找出对象被保留和释放的位置,以便您可以追踪哪个释放是不合适的。 http://www.markj.net/iphone-memory-debug-nszombie/

祝你好运!

Run your app with NSZombieEnabled set to yes. See http://www.cocoadev.com/index.pl?NSZombieEnabled for an explanation about it and how to set it. I think what you will find is that the app will now throw an exception in the simulator telling you that you are sending a message to an object that has been released.

Based on the error message you are receiving, I expect the culprit is a NSString or NSMutableString object. If it is an NSString then warning, that NSString could be shared by several different objects so figuring out where the extra release is might be hard.

Never fear though, Instruments helps tremendously in this regard. Here is a link that explains how to use Instruments to find out exactly where your object is being retained and released so you can track down which release is inappropriate. http://www.markj.net/iphone-memory-debug-nszombie/

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文