nsproxy

CORBA on Mac OS X (Cocoa)

為{幸葍}努か 提交于 2019-12-22 14:54:53
问题 I am currently looking into different ways to support distributed model objects (that is, a computational model that runs on several different computers) in a project that initially focuses on Mac OS X (using Cocoa). As far as I know there is the possibility to use the class cluster around NSProxy . But there also seem to be implementations of CORBA around with Objective-C support. At a later time there may be the need to also support/include Windows machines. In that case I would need to use

How does NSProxy “transform itself into another object”?

送分小仙女□ 提交于 2019-12-20 19:36:12
问题 The NSProxy Class Reference says this: Typically, a message to a proxy is forwarded to the real object or causes the proxy to load (or transform itself into) the real object. How exactly would the "transform itself into the real object" work? To make things a little more specific, suppose class Foo has a method newFooWithString: that takes a string and returns a new instance of Foo . Would it be possible to setup an NSProxy that sits around, and if a pleaseBecomeAFooUsingString: @"bar"

NSProxy and Key Value Observing

一世执手 提交于 2019-12-20 09:56:29
问题 NSProxy seems to work very well as stand-in objects for those that don't yet exist. For example. - (NSMethodSignature *)methodSignatureForSelector:(SEL)sel { return [self.target methodSignatureForSelector:sel]; } - (void)forwardInvocation:(NSInvocation *)invocation { [invocation invokeWithTarget:self.target]; } The above code will transparently pass any method invocation to the target that the proxy represents. However, it doesn't seem to handle KVO observations and notifications on the

Real examples where NSProxy class is useful and why?

此生再无相见时 提交于 2019-12-06 19:52:04
问题 I have been wondering why is NSProxy class so important. Why does an object need to keep its instance variables inside other objects? I need examples to understand when to use it. Thanks! 回答1: Example A: Imagine you'd be writing an object persistence layer (like CoreData, but much better of course ;) ). Let's say you can fulfill a query for thousands of items in your database really quick by just looking at the index-tree, without the cost of reading and initializing the complete item. You

Real examples where NSProxy class is useful and why?

半城伤御伤魂 提交于 2019-12-05 01:33:13
I have been wondering why is NSProxy class so important. Why does an object need to keep its instance variables inside other objects? I need examples to understand when to use it. Thanks! Example A: Imagine you'd be writing an object persistence layer (like CoreData, but much better of course ;) ). Let's say you can fulfill a query for thousands of items in your database really quick by just looking at the index-tree, without the cost of reading and initializing the complete item. You could use NSProxy to implement lazy-loading. Use your index table to locate the primary key of the object, but

[译]2013-10-25 NSObject: the Class and the Protocol

◇◆丶佛笑我妖孽 提交于 2019-12-03 13:22:56
原文链接: https://mikeash.com/pyblog/friday-qa-2013-10-25-nsobject-the-class-and-the-protocol.html Reader Tomas Bouda asks: what's the deal with the NSObject protocol? There are two NSObjects in Cocoa, a class and a protocol. Why both? What purpose do they serve? In today's article, I'll explore the answer to this question. 读者Tomas Bouda问我:“NSObject协议应该怎么理解呢?在Cocoa中有两处NSObject,一处是NSObject类,另一处是NSObject协议。为啥会有两个呢?他们到底有什么作用?”。在今天的文章里,我将会探讨这个问题。 Namespaces 命名空间 First, let's look at how these two entities with the same name can coexist. Classes and protocols in Objective-C inhabit entirely separate

How does NSProxy “transform itself into another object”?

↘锁芯ラ 提交于 2019-12-03 07:01:40
The NSProxy Class Reference says this: Typically, a message to a proxy is forwarded to the real object or causes the proxy to load (or transform itself into) the real object. How exactly would the "transform itself into the real object" work? To make things a little more specific, suppose class Foo has a method newFooWithString: that takes a string and returns a new instance of Foo . Would it be possible to setup an NSProxy that sits around, and if a pleaseBecomeAFooUsingString: @"bar" message is received, transforms itself into [Foo newFooWithString: @"bar"] , occupying the same memory,

NSProxy and Key Value Observing

╄→гoц情女王★ 提交于 2019-12-02 20:50:46
NSProxy seems to work very well as stand-in objects for those that don't yet exist. For example. - (NSMethodSignature *)methodSignatureForSelector:(SEL)sel { return [self.target methodSignatureForSelector:sel]; } - (void)forwardInvocation:(NSInvocation *)invocation { [invocation invokeWithTarget:self.target]; } The above code will transparently pass any method invocation to the target that the proxy represents. However, it doesn't seem to handle KVO observations and notifications on the target. I tried to use a NSProxy subclass as standing for objects to be passed to NSTableView , but I'm

How can I get OCMock under ARC to stop nilling an NSProxy subclass set using a weak property?

馋奶兔 提交于 2019-11-29 14:09:07
问题 Under ARC , I have an object, Child that has a weak property, parent . I'm trying to write some tests for Child , and I'm mocking its parent property using OCMock . Under ARC, setting an NSProxy subclass using a synthesized weak property setter doesn't set the property ... the line after the weak property is set, checking it reveals that it's already nil . Here's the concrete example: @interface Child : NSObject @property (nonatomic, weak) id <ParentInterface>parent; @end @implementation