I'm making a simple app that retrieves data from a sqlite3 database and places it into a table view. I've set up an add function that pulls up a modal view controller and lets you add new data to the database, but how do I make the table view refresh when the modal view controller is dismissed? I've tried reloadData in viewWillAppear and many other methods. The new data does get added to the table view, and I can scroll around, but once I scroll down to where the new cell is, the application crashes. When I reopen the application, the new entry is in the table view and it runs without any errors. I'm using the most updated version of the SDK currently.
I'm making a simple app that retrieves data from a sqlite3 database and places it into a table view. I've set up an add function that pulls up a modal view controller and lets you add new data to the database, but how do I make the table view refresh when the modal view controller is dismissed? I've tried reloadData in viewWillAppear and many other methods. The new data does get added to the table view, and I can scroll around, but once I scroll down to where the new cell is, the application crashes. When I reopen the application, the new entry is in the table view and it runs without any errors. I'm using the most updated version of the SDK currently.
You have to be careful that your table view's data source returns the correct number of rows and sections, and serves up data that matches the counts you provide. If there's a mismatch, you crash. Look at the specific error code to figure out what's going wrong.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
I'm relatively new to this, and the debug console is giving an error that says "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString pokemonName]: unrecognized selector sent to instance 0x4bb0b40'". I'm having trouble understanding what an NSCFString is
Whats your declaration for pokemonName? And how is it used in your tableView? I am assuming that the pokemonName is a string.
Quote:
Originally Posted by Starhopper108
I'm relatively new to this, and the debug console is giving an error that says "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString pokemonName]: unrecognized selector sent to instance 0x4bb0b40'". I'm having trouble understanding what an NSCFString is
Whats your declaration for pokemonName? And how is it used in your tableView? I am assuming that the pokemonName is a string.
I have it declared in the pokemon object header file as, yes, an NSString. I'm taking the text from a textField where you input the name of a new entry and placing it in an 'insert into' sql statement that I convert into a UTF8String, and then I add the saved name to the NSMutableArray that the tableView gets its data from.
I'm relatively new to this, and the debug console is giving an error that says "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString pokemonName]: unrecognized selector sent to instance 0x4bb0b40'". I'm having trouble understanding what an NSCFString is
Post the code that's generating the error, as well as the header for the class that includes the "pokemonName" property.
There are 2 likely causes of this error:
You've got an error in your code and are trying to ask a string object for a "pokemonName" property.
You have an object that's over-released, and that memory location is being replaced with a new object of a different type.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.