简体   繁体   中英

Works in iPhone Simulator, but not on Phone

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.

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.

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!

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM