Example A: Imagine writing a persistence level for objects (for example, CoreData, but, of course, much better);)
Let's say you can query thousands of items in your database very quickly just by looking at the index tree, without the cost of reading and initializing the entire item. You can use NSProxy to implement lazy loading. Use your index table to find the primary key of the object, but instead of creating this object, return an NSProxy that knows the primary key of the real object.
Only when another database search is required, the proxy object creates an element and redirects all future messages to it. The calling code will only deal with the NSProxy element and will never be about lazy loading being done under the hood.
Example B (this is OS X, sorry): NSOutlineView behaves very strangely when you use the same element twice in a hierarchical structure. A very common problem when you have a smart group feature in your application. Solution: use different proxies in the form of a contour, pointing to the same object.
iljawascoding
source share