Re: How to implement lazy loading with a proxied array
Re: How to implement lazy loading with a proxied array
- Subject: Re: How to implement lazy loading with a proxied array
- From: Kyle Sluder <email@hidden>
- Date: Sat, 7 Aug 2010 10:04:09 -0700
On Aug 7, 2010, at 9:42 AM, Dave DeLong <email@hidden> wrote:
> Let's say that I have an object that encapsulates a Google search. I feed this object my query string, set some options, and then execute it. Ideally, I'd like to get back an NSArray of all the results, but 1) that isn't practical and 2) the Google API doesn't support that.
>
> So what if I use an NSProxy? Can I return an NSProxy in place of the array that knows how many total results there are, and then as the user asks for more and more results, it just silently executes "paged" searches to get the next batch?
This sounds like a bad idea. It might work, but it will introduce hard-to-follow network access. What if someone asks the array for -lastObject? Or -reverseObjectEnumerator?
Since I guarantee at some point clients of your searching logic are going to need to be aware of the nature of Google API searching (in other words, your abstraction will leak), it would be best to expose on your Google-searching controller object specific API for paging through results. It might be as simple as a -loadMore method and a resultsSoFar NSArray property.
--Kyle Sluder_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden