Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-23-2012, 07:37 AM   #1 (permalink)
Token farm animal
 
sneaky's Avatar
 
Join Date: Apr 2011
Posts: 321
sneaky is on a distinguished road
Default Safe to cache NSManagedObjects in an array?

I have an app that queries the Core Data database for the same couple of objects over and over, sometimes at a pretty high rate.

The database is pretty big but in the most common use case the app require the same set of (about 50 at any given time) objects over and over. There are a lot of different places where the objects are needed so to cater for every possible scenario I must ask for the NSManagedObject I need every time as I could be needing a different object.

To speed things up I have a simple NSMutableArray of 100 length that I use as a FIFO buffer for the NSManagedObjects. Then as I need an object I loop through the array of objects and if the object I'm after is there it is being returned - Otherwise I query the database and add the resulting NSManagedObject to my buffer.

This has sped up my application significantly and I have not had any problems with this in testing but I still wonder if this is safe (and recommended) to do. Is there perhaps already some predefined buffer I should be using? (i.e. am I re-inventing the wheel?)
sneaky is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 383
10 members and 373 guests
7twenty7, Atatator, FrankWeller, glenn_sayers, iphonedevshani, MAMN84, mraalex, QuantumDoja, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:48 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0