Questions tagged [nsproxy]

NSProxy is an abstract superclass defining an API for objects that act as stand-ins for other objects or for objects that don’t exist yet. 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. Subclasses of NSProxy can be used to implement transparent distributed messaging (for example, NSDistantObject) or for lazy instantiation of objects that are expensive to create.

NSProxy is an abstract superclass defining an API for objects that act as stand-ins for other objects or for objects that don’t exist yet. 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. Subclasses of NSProxy can be used to implement transparent distributed messaging (for example, NSDistantObject) or for lazy instantiation of objects that are expensive to create.

NSProxy implements the basic methods required of a root class, including those defined in the NSObject protocol. However, as an abstract class it doesn’t provide an initialization method, and it raises an exception upon receiving any message it doesn’t respond to. A concrete subclass must therefore provide an initialization or creation method and override the forwardInvocation: and methodSignatureForSelector: methods to handle messages that it doesn’t implement itself. A subclass’s implementation of forwardInvocation: should do whatever is needed to process the invocation, such as forwarding the invocation over the network or loading the real object and passing it the invocation. methodSignatureForSelector: is required to provide argument type information for a given message; a subclass’s implementation should be able to determine the argument types for the messages it needs to forward and should construct an NSMethodSignature object accordingly. See the NSDistantObject, NSInvocation, and NSMethodSignature class specifications for more information.

26 questions
2
votes
1 answer

Internal calls on my proxied class don't get routed through proxy

I was using method swizzling to wrap all method invocations in a class with some extra functionality. Specifically I was: Checking if the required object for this method call was in the cache If the cache had that object return it. If not, dispatch…
Jasper Blues
  • 28,258
  • 22
  • 102
  • 185
1
vote
1 answer

NSObject why is alloc declared in both NSObject and NSProxy yet retain is in the NSObject protocol

retain is declared in NSObject protocol. Therefore NSObject class and NSProxy class implement it. yet both NSProxy and NSObject classes both have an alloc. Why isnt alloc declared in NSObject protocol? Side question: NSObject protocol is also used…
brian.clear
  • 5,277
  • 2
  • 41
  • 62
1
vote
1 answer

Is it possible to intercept all method class on any UIViewController subclass

Let's say I wanted to be able to intercept any method calls to a UIViewController subclass. First of all, I swizzle the +(instancetype)alloc method and I check if the current instance isKindOfClass:[UIViewController class]. If it is I go ahead and…
iOSAddicted
  • 389
  • 1
  • 17
1
vote
0 answers

NSProxy incompatible pointer types

I have an NSProxy subclass called EBManagedObject and an NSObject subclass called EBObject. EBManagedObject is initialized with a guid that is used to retrieve an EBObject from EBObjectRepository. EBManagedObject will forward any message sent to it…
Erik B
  • 40,889
  • 25
  • 119
  • 135
1
vote
2 answers

How to send not declared selector without performSelector:?

Background: I have an object (let's call it BackendClient) that represents connection with server. Its methods are generated to single @protocol and they are all synchronous, so I want to create proxy object that will call them in background. The…
folex
  • 5,122
  • 1
  • 28
  • 48
1
vote
1 answer

NSProxy with forwardInvocation with self - possible?

I've set up NSProxy, forwardInvocation etc to capture messages passed to an object - it all works fine. What I want to also do is capture messages passed by self e.g.: [self doSomething] or self.myVal = 5; It doesn't seem to work ... is this…
akbsteam
  • 253
  • 2
  • 16
0
votes
0 answers

Can NSProxy stand in for NSView subclasses?

I've tried a simple test which results in EXC_BAD_ACCESS error: #import "AppDelegate.h" @interface CrashingProxy : NSProxy @property (strong) id target; - (instancetype)initWithTarget:(id)targetObj; @end @implementation CrashingProxy @synthesize…
Boris D.
  • 388
  • 1
  • 5
  • 8
0
votes
0 answers

NSProxy and delegation

I,m must add some features for framework which constructing flexible datasource for UICollectionView and UITableView. I have class import UIKit public class SimpleTableController: AbstractController, UITableViewDelegate, UITableViewDataSource…
0
votes
1 answer

How to get selected objects from NSArrayController without a proxy object?

I am trying to implement copying and pasting of multiple objects in an NSTableView backed by an NSArrayController. My copy: method looks like this: - (IBAction)copy:(id)sender { if (self.arrayController.selectionIndexes.count > 0) { …
DanielGibbs
  • 9,910
  • 11
  • 76
  • 121
0
votes
1 answer

NSProxy and forwardInvocation: invoke called within a block causes nil return value

I am using a NSProxy subclass and forwardInvocation: for capturing calls to my Backend API object (a shared instance). Some Background information: I want to capture the API calls so I can check everytime if I have to refresh my authentication…
orschaef
  • 1,287
  • 10
  • 27
-1
votes
1 answer

NSProxy forwardInvocation: Return an new NSProxy instance cause memory leak

I try to use NSProxy to wrap object and make an proxy instance in (forwardInvocation:) as invocation' retValue, but all proxyon instance from can't be release in ARC. I've been troubled for a long time. demo at…
1
2