Class: NSPort

Inherits:
NSObject show all

Overview

NSPort is an abstract class that represents a communication channel. Communication occurs between NSPort objects, which typically reside in different threads or tasks. The distributed objects system uses NSPort objects to send NSPortMessage objects back and forth. You should implement interapplication communication using distributed objects whenever possible and use NSPort objects only when necessary.

Direct Known Subclasses

NSMachPort, NSMessagePort

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Class Method Details

+ (NSPort) port

Creates and returns a new NSPort object capable of both sending and receiving messages.

Returns:

  • (NSPort)

    A new NSPort object capable of both sending and receiving messages.

Instance Method Details

- (Object) delegate

Returns the receiver’s delegate.

Returns:

  • (Object)

    The receiver’s delegate.

- (Object) invalidate

Marks the receiver as invalid and posts an NSPortDidBecomeInvalidNotification to the default notification center. You must call this method before releasing a port object (or removing strong references to it if your application is garbage collected).

Returns:

- (Boolean) isValid

Returns a Boolean value that indicates whether the receiver is valid. An NSPort object becomes invalid when its underlying communication resource, which is operating system dependent, is closed or damaged.

Returns:

  • (Boolean)

    NO if the receiver is known to be invalid, otherwise YES.

- (Object) removeFromRunLoop(runLoop, forMode:mode)

This method should be implemented by a subclass to stop monitoring of a port when removed from a give run loop in a given input mode. This method should not be called directly.

Parameters:

  • runLoop (NSRunLoop)

    The run loop from which to remove the receiver.

  • mode (String)

    The run loop mode from which to remove the receiver

Returns:

- (Integer) reservedSpaceLength

Returns the number of bytes of space reserved by the receiver for sending data.

Returns:

  • (Integer)

    The number of bytes reserved by the receiver for sending data. The default length is 0.

- (Object) scheduleInRunLoop(runLoop, forMode:mode)

This method should be implemented by a subclass to set up monitoring of a port when added to a given run loop in a given input mode. This method should not be called directly.

Parameters:

  • runLoop (NSRunLoop)

    The run loop to which to add the receiver.

  • mode (String)

    The run loop mode to which to add the receiver

Returns:

- (Boolean) sendBeforeDate(limitDate, components:components, from:receivePort, reserved:headerSpaceReserved)

This method is provided for subclasses that have custom types of NSPort. NSConnection calls this method at the appropriate times. This method should not be called directly. This method could raise an NSInvalidSendPortException, NSInvalidReceivePortException, or an NSPortSendException, depending on the type of send port and the type of error.

Parameters:

  • limitDate (NSDate)

    The last instant that a message may be sent.

  • components (Array)

    The message components.

  • receivePort (NSPort)

    The receive port.

  • headerSpaceReserved (Integer)

    The number of bytes reserved for the header.

Returns:

  • (Boolean)

- (Boolean) sendBeforeDate(limitDate, msgid:msgID, components:components, from:receivePort, reserved:headerSpaceReserved)

This method is provided for subclasses that have custom types of NSPort. NSConnection calls this method at the appropriate times. This method should not be called directly. This method could raise an NSInvalidSendPortException, NSInvalidReceivePortException, or an NSPortSendException, depending on the type of send port and the type of error.

Parameters:

  • limitDate (NSDate)

    The last instant that a message may be sent.

  • msgID (Integer)

    The message ID.

  • components (Array)

    The message components.

  • receivePort (NSPort)

    The receive port.

  • headerSpaceReserved (Integer)

    The number of bytes reserved for the header.

Returns:

  • (Boolean)

- (Object) setDelegate(anObject)

Sets the receiver’s delegate to a given object.

Parameters:

  • anObject (Object)

    The delegate for the receiver.

Returns: