Wednesday, November 11, 2009

Navigation-based Application Core Data Template

I've updated the Navigation-Based Core Data Application Xcode project to include a suggested workaround to a problem in NSFetchedResultsController. I believe this problem only existed in SDK 3.0 and was later fixed, but for backwards compatibility, I've added the workaround to the project template for anyone interested in supporting 3.0 users.

As before, unzip and copy the folder to this location, replacing the one that's there:

/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application/Navigation-based Application/
Note: I updated the project yet again, at 1:11 pm Eastern time, to deal with a problem with inserting the first object when using a section name key path. Because tables can't have zero sections, this new version checks to make sure before inserting a new section, that it isn't an empty table getting its first row. In that case, the table will already have one section and doesn't need a second. Adding a second in that scenario causes a crash.
Note Again: Another update to the project at 10:21 eastern time on November 11. Fixed a few more issues I found. I hope this will be the last version.
Note Yet Again: I forgot to move the update into the right folder on the web server, so the 10:21 eastern time update actually happened at 10:59. Re-download if you grabbed it between those times.



Thanks to Simon Wolf for catching it



10 comments:

Malcolm Hall said...

What problem are you talking about? The one I am aware of is when you delete the last row in the table.

Simon Wolf (@sgaw) said...

Malcolm, you can find my comment in Jeff's earlier post at http://iphonedevelopment.blogspot.com/2009/11/nsfetchedresultscontroller.html

bobby1234 said...

Jeff you have a little typo in the title... template not tempalte

Jeff LaMarche said...

bobby:

Thanks. Matches my state of mind lately - chaotic and not 100% right. :)

Jeff

Adam said...

Jeff, is it possible this way to completely change the NSFetchRequest on the fly? Say for instance I had a segmented control that toggled accessing sort or just removed/added the option of having sections. Is this possible?

can i just make a new FetchRequest and do
can i just change fetchRequestController.fetchRequest = newFetchRequest
or do i need to make a completely new fetch controller?

Jeff LaMarche said...

Adam:

I actually do that for one of the book projects so that a tab view controller can change the sort ordering, but I was not able to find a way to change the FetchRequest or the sort ordering that the NSFetchedResultsController used, so I basically set it to nil and reload. In my accessor for the fetched results controller, I check the tab and create the sort ordering based on the selected tab. It's not ideal, but it works.

Adam said...

Thanks Jeff! Just wanted to add that your book was a great read (I have the older edition but downloaded the 3.0 code).

chang said...

Really great ideas. I like every example. Just might have to try these...
more template

Edwin said...

scrub m65 kamagra attorney lawyer body scrub field jacket lovegra marijuana attorney injury lawyer

h4ns said...

What youre saying is completely true. I know that everybody must say the same thing, but I just think that you put it in a way that everyone can understand. I also love the images you put in here. They fit so well with what youre trying to say. Im sure youll reach so many people with what youve got to say.

Arsenal vs Huddersfield Town live streaming
Arsenal vs Huddersfield Town live streaming
Wolverhampton Wanderers vs Stoke City Live Streaming
Wolverhampton Wanderers vs Stoke City Live Streaming
Notts County vs Manchester City Live Streaming
Notts County vs Manchester City Live Streaming
Bologna vs AS Roma Live Streaming
Bologna vs AS Roma Live Streaming
Juventus vs Udinese Live Streaming
Juventus vs Udinese Live Streaming
Napoli vs Sampdoria Live Streaming
Napoli vs Sampdoria Live Streaming
Fulham vs Tottenham Hotspur Live Streaming
Fulham vs Tottenham Hotspur Live Streaming
AS Monaco vs Marseille Live Streaming
AS Monaco vs Marseille Live Streaming
Alajuelense vs Perez Zeledon Live Streaming
Alajuelense vs Perez Zeledon Live Streaming
Technology News | News Today | Live Streaming TV Channels