How to implement lazy loading with a proxied array
How to implement lazy loading with a proxied array
- Subject: How to implement lazy loading with a proxied array
- From: Dave DeLong <email@hidden>
- Date: Sat, 07 Aug 2010 10:42:55 -0600
Hi everyone,
Disclaimer: I have never touched NSProxy before; I've just read some documentation.
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?
I'm guessing that the answer to this is "Yes", since I think I've seen stuff like that before. I think I understand that in order to implement this, I'll need to subclass NSProxy and override methodSignatureForSelector: and forwardInvocation:. However, here's where my question arises:
There are many different ways of retrieving objects out of an NSArray, namely:
- objectAtIndex:
- countByEnumeratingWithState:objects:count:
- enumerateObjects(AtIndexes...)(UsingBlock...)(WithOptions...)
- filteredArrayUsingPredicate:
- getObjects:range:
- valueForKey:
(to name a few)
Would my array proxy have to satisfy all of these? This is a proxy that (theoretically) I'd be exposing to other developers (since I'm writing a framework), so how many cases of object retrieval do I need to cover?
I guess the short version of this question is "where do I begin?"
Thanks,
Dave
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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