ObjFW
Loading...
Searching...
No Matches
OFObject Class Reference

The root class for all other classes inside ObjFW. More...

#include <ObjFW/ObjFW.h>

Inheritance diagram for OFObject:
<OFObject> OFAllocFailedException OFApplication OFArray OFBlock OFCharacterSet OFColor OFDNSQuery OFDNSResolver OFDNSResourceRecord OFDNSResponse OFData OFDatagramSocket OFDate OFDictionary OFEnumerator OFException OFFileManager OFHMAC OFHTTPClient OFHTTPCookie OFHTTPCookieManager OFHTTPRequest OFHTTPServer OFINIFile OFINISection OFIRI OFIRIHandler OFInvocation OFKernelEventObserver OFLHAArchive OFLHAArchiveEntry OFList OFLocale OFMD5Hash OFMapTable OFMapTableEnumerator OFMatrix4x4 OFMessagePackExtension OFMethodSignature OFMutex OFNotification OFNotificationCenter OFNull OFOptionsParser OFPair OFPlugin OFRIPEMD160Hash OFRecursiveMutex OFRunLoop OFSHA1Hash OFSHA224Or256Hash OFSHA384Or512Hash OFSequencedPacketSocket OFSet OFSettings OFStream OFString OFSystemInfo OFTarArchive OFTarArchiveEntry OFThread OFTimer OFTriple OFUUID OFValue OFXMLElementBuilder OFXMLNode OFXMLParser OFZIPArchive OFZIPArchiveEntry OFZooArchive OFZooArchiveEntry OHDualSenseGamepad OHDualShock4Gamepad OHGameController OHGameControllerElement OHJoyConPair OHLeftJoyCon OHN64Controller OHRightJoyCon OHStadiaGamepad OHXboxGamepad OTTestCase

Instance Methods

(instancetype) - init
 Initializes an already allocated object.
 
(nullable OFMethodSignature *) - methodSignatureForSelector:
 Returns the method signature for the specified selector.
 
(void) - dealloc
 Deallocates the object.
 
(void) - performSelector:afterDelay:
 Performs the specified selector after the specified delay.
 
(void) - performSelector:withObject:afterDelay:
 Performs the specified selector with the specified object after the specified delay.
 
(void) - performSelector:withObject:withObject:afterDelay:
 Performs the specified selector with the specified objects after the specified delay.
 
(void) - performSelector:withObject:withObject:withObject:afterDelay:
 Performs the specified selector with the specified objects after the specified delay.
 
(void) - performSelector:withObject:withObject:withObject:withObject:afterDelay:
 Performs the specified selector with the specified objects after the specified delay.
 
(void) - performSelector:onThread:waitUntilDone:
 Performs the specified selector on the specified thread.
 
(void) - performSelector:onThread:withObject:waitUntilDone:
 Performs the specified selector on the specified thread with the specified object.
 
(void) - performSelector:onThread:withObject:withObject:waitUntilDone:
 Performs the specified selector on the specified thread with the specified objects.
 
(void) - performSelector:onThread:withObject:withObject:withObject:waitUntilDone:
 Performs the specified selector on the specified thread with the specified objects.
 
(void) - performSelector:onThread:withObject:withObject:withObject:withObject:waitUntilDone:
 Performs the specified selector on the specified thread with the specified objects.
 
(void) - performSelectorOnMainThread:waitUntilDone:
 Performs the specified selector on the main thread.
 
(void) - performSelectorOnMainThread:withObject:waitUntilDone:
 Performs the specified selector on the main thread with the specified object.
 
(void) - performSelectorOnMainThread:withObject:withObject:waitUntilDone:
 Performs the specified selector on the main thread with the specified objects.
 
(void) - performSelectorOnMainThread:withObject:withObject:withObject:waitUntilDone:
 Performs the specified selector on the main thread with the specified objects.
 
(void) - performSelectorOnMainThread:withObject:withObject:withObject:withObject:waitUntilDone:
 Performs the specified selector on the main thread with the specified objects.
 
(void) - performSelector:onThread:afterDelay:
 Performs the specified selector on the specified thread after the specified delay.
 
(void) - performSelector:onThread:withObject:afterDelay:
 Performs the specified selector on the specified thread with the specified object after the specified delay.
 
(void) - performSelector:onThread:withObject:withObject:afterDelay:
 Performs the specified selector on the specified thread with the specified objects after the specified delay.
 
(void) - performSelector:onThread:withObject:withObject:withObject:afterDelay:
 Performs the specified selector on the specified thread with the specified objects after the specified delay.
 
(void) - performSelector:onThread:withObject:withObject:withObject:withObject:afterDelay:
 Performs the specified selector on the specified thread with the specified objects after the specified delay.
 
(nullable id) - forwardingTargetForSelector:
 This method is called when resolveClassMethod: or resolveInstanceMethod: returned false. It should return a target to which the message should be forwarded.
 
(void) - doesNotRecognizeSelector:
 Handles messages which are not understood by the receiver.
 
- Instance Methods inherited from <OFObject>
(unsigned long) - hash
 Returns a hash for the object.
 
(unsigned int) - retainCount
 Returns the retain count.
 
(bool) - isProxy
 Returns whether the object is a proxy object.
 
(bool) - isKindOfClass:
 Returns a boolean whether the object is of the specified kind.
 
(bool) - isMemberOfClass:
 Returns a boolean whether the object is a member of the specified class.
 
(bool) - respondsToSelector:
 Returns a boolean whether the object responds to the specified selector.
 
(nullable IMP- methodForSelector:
 Returns the implementation for the specified selector.
 
(nullable id) - performSelector:
 Performs the specified selector.
 
(nullable id) - performSelector:withObject:
 Performs the specified selector with the specified object.
 
(nullable id) - performSelector:withObject:withObject:
 Performs the specified selector with the specified objects.
 
(nullable id) - performSelector:withObject:withObject:withObject:
 Performs the specified selector with the specified objects.
 
(nullable id) - performSelector:withObject:withObject:withObject:withObject:
 Performs the specified selector with the specified objects.
 
(bool) - isEqual:
 Checks two objects for equality.
 
(instancetype) - retain
 Increases the retain count.
 
(void) - release
 Decreases the retain count.
 
(instancetype) - autorelease
 Adds the object to the topmost autorelease pool of the thread's autorelease pool stack.
 
(instancetype) - self
 Returns the receiver.
 
(bool) - allowsWeakReference
 Returns whether the object allows a weak reference.
 
(bool) - retainWeakReference
 Retain a weak reference to this object.
 

Class Methods

(void) + load
 A method which is called once when the class is loaded into the runtime.
 
(void) + unload
 A method which is called when the class is unloaded from the runtime.
 
(void) + initialize
 A method which is called the moment before the first call to the class is being made.
 
(instancetype) + alloc
 Allocates memory for an instance of the class and sets up the memory pool for the object.
 
(Class) + class
 Returns the class.
 
(OFString *) + className
 Returns the name of the class as a string.
 
(bool) + isSubclassOfClass:
 Returns a boolean whether the class is a subclass of the specified class.
 
(nullable Class) + superclass
 Returns the superclass of the class.
 
(bool) + instancesRespondToSelector:
 Checks whether instances of the class respond to a given selector.
 
(bool) + conformsToProtocol:
 Checks whether the class conforms to a given protocol.
 
(nullable IMP+ instanceMethodForSelector:
 Returns the implementation of the instance method for the specified selector.
 
(nullable OFMethodSignature *) + instanceMethodSignatureForSelector:
 Returns the method signature of the instance method for the specified selector.
 
(OFString *) + description
 Returns a description for the class, which is usually the class name.
 
(nullable IMP+ replaceClassMethod:withMethodFromClass:
 Replaces a class method with a class method from another class.
 
(nullable IMP+ replaceInstanceMethod:withMethodFromClass:
 Replaces an instance method with an instance method from another class.
 
(void) + inheritMethodsFromClass:
 Adds all methods from the specified class to the class that is the receiver.
 
(bool) + resolveClassMethod:
 Try to resolve the specified class method.
 
(bool) + resolveInstanceMethod:
 Try to resolve the specified instance method.
 
(id) + copy
 Returns the class.
 

Properties

OFStringclassName
 The name of the object's class.
 
OFStringdescription
 A description for the object.
 

Detailed Description

The root class for all other classes inside ObjFW.

Method Documentation

◆ alloc

+ (instancetype) alloc

Allocates memory for an instance of the class and sets up the memory pool for the object.

This method will never return nil.

Returns
The allocated object
Exceptions
OFAllocFailedExceptionThere was not enough memory to allocate the object
OFInitializationFailedExceptionThe instance could not be constructed

◆ class

+ (Class) class

Returns the class.

Returns
The class

Reimplemented from <OFObject>.

◆ className

+ (OFString *) className

Returns the name of the class as a string.

Returns
The name of the class as a string

◆ conformsToProtocol:

+ (bool) conformsToProtocol: (Protocol *) protocol

Checks whether the class conforms to a given protocol.

Parameters
protocolThe protocol which should be checked for conformance
Returns
A boolean whether the class conforms to the specified protocol

Reimplemented from <OFObject>.

◆ copy

+ (id) copy

Returns the class.

This method exists so that classes can be used in collections requiring conformance to the OFCopying protocol.

Returns
The class of the object

◆ dealloc

- (void) dealloc

Deallocates the object.

It is automatically called when the retain count reaches zero.

This also frees all memory in its memory pool.

◆ description

+ (OFString *) description

Returns a description for the class, which is usually the class name.

This is mostly for debugging purposes.

Returns
A description for the class, which is usually the class name

Reimplemented in OFAllocFailedException, and OFException.

◆ doesNotRecognizeSelector:

- (void) doesNotRecognizeSelector: (SEL) selector

Handles messages which are not understood by the receiver.

Warning
If you override this method, you must make sure that it never returns!
Parameters
selectorThe selector not understood by the receiver
Exceptions
OFNotImplementedExceptionThe method is not implemented

◆ forwardingTargetForSelector:

- (id) forwardingTargetForSelector: (SEL) selector

This method is called when resolveClassMethod: or resolveInstanceMethod: returned false. It should return a target to which the message should be forwarded.

Note
When the message should not be forwarded, you should not return nil, but instead return the result of [super forwardingTargetForSelector: selector].
Returns
The target to forward the message to

◆ inheritMethodsFromClass:

+ (void) inheritMethodsFromClass: (Class) class_

Adds all methods from the specified class to the class that is the receiver.

Methods implemented by the receiving class itself will not be overridden, however methods implemented by its superclass will. Therefore it behaves similar as if the specified class is the superclass of the receiver.

All methods from the superclasses of the specified class will also be added.

If the specified class is a superclass of the receiving class, nothing is done.

The methods which will be added from the specified class are not allowed to use super or access instance variables, instead they have to use accessors.

Parameters
class_The class from which the instance methods should be inherited

◆ init

- (instancetype) init

Initializes an already allocated object.

Derived classes may override this, but need to use the following pattern:

self = [super init];
@try {
// Custom initialization code goes here.
} @catch (id e) {
@throw e;
}
return self;
instancetype init()
Initializes an already allocated object.
Definition OFObject.m:696
instancetype self()
Returns the receiver.
void release()
Decreases the retain count.

With ARC enabled, the following pattern needs to be used instead:

self = [super init];
// Custom initialization code goes here.
return self;

init may never return nil, instead an exception (for example OFInitializationFailedException) should be thrown.

Returns
An initialized object

Reimplemented in OFArray, OFData, OFDictionary, OFDNSResolver, OFLocale, OFMutableArray, OFMutableDictionary, OFMutableSet, OFSet, OFString, and OFUUID.

◆ initialize

+ (void) initialize

A method which is called the moment before the first call to the class is being made.

Derived classes can override this to execute their own code on initialization. They should make sure to not execute any code if self is not the class itself, as it might happen that the method was called for a subclass which did not override this method.

◆ instanceMethodForSelector:

+ (IMP) instanceMethodForSelector: (SEL) selector

Returns the implementation of the instance method for the specified selector.

Parameters
selectorThe selector for which the method should be returned
Returns
The implementation of the instance method for the specified selector or nil if it isn't implemented

◆ instanceMethodSignatureForSelector:

+ (OFMethodSignature *) instanceMethodSignatureForSelector: (SEL) selector

Returns the method signature of the instance method for the specified selector.

Parameters
selectorThe selector for which the method signature should be returned
Returns
The method signature of the instance method for the specified selector

◆ instancesRespondToSelector:

+ (bool) instancesRespondToSelector: (SEL) selector

Checks whether instances of the class respond to a given selector.

Parameters
selectorThe selector which should be checked for respondence
Returns
A boolean whether instances of the class respond to the specified selector

◆ isSubclassOfClass:

+ (bool) isSubclassOfClass: (Class) class_

Returns a boolean whether the class is a subclass of the specified class.

Parameters
class_The class which is checked for being a superclass
Returns
A boolean whether the class is a subclass of the specified class

◆ load

+ (void) load

A method which is called once when the class is loaded into the runtime.

Derived classes can override this to execute their own code when the class is loaded.

◆ methodSignatureForSelector:

- (OFMethodSignature *) methodSignatureForSelector: (SEL) selector

Returns the method signature for the specified selector.

Parameters
selectorThe selector for which the method signature should be returned
Returns
The method signature for the specified selector

◆ performSelector:afterDelay:

- (void) performSelector: (SEL) selector
afterDelay: (OFTimeInterval) delay 

Performs the specified selector after the specified delay.

Parameters
selectorThe selector to perform
delayThe delay after which the selector will be performed

◆ performSelector:onThread:afterDelay:

- (void) performSelector: (SEL) selector
onThread: (OFThread *) thread
afterDelay: (OFTimeInterval) delay 

Performs the specified selector on the specified thread after the specified delay.

Parameters
selectorThe selector to perform
threadThe thread on which to perform the selector
delayThe delay after which the selector will be performed

◆ performSelector:onThread:waitUntilDone:

- (void) performSelector: (SEL) selector
onThread: (OFThread *) thread
waitUntilDone: (bool) waitUntilDone 

Performs the specified selector on the specified thread.

Parameters
selectorThe selector to perform
threadThe thread on which to perform the selector
waitUntilDoneWhether to wait until the perform finished

◆ performSelector:onThread:withObject:afterDelay:

- (void) performSelector: (SEL) selector
onThread: (OFThread *) thread
withObject: (nullable id) object
afterDelay: (OFTimeInterval) delay 

Performs the specified selector on the specified thread with the specified object after the specified delay.

Parameters
selectorThe selector to perform
threadThe thread on which to perform the selector
objectThe object that is passed to the method specified by the selector
delayThe delay after which the selector will be performed

◆ performSelector:onThread:withObject:waitUntilDone:

- (void) performSelector: (SEL) selector
onThread: (OFThread *) thread
withObject: (nullable id) object
waitUntilDone: (bool) waitUntilDone 

Performs the specified selector on the specified thread with the specified object.

Parameters
selectorThe selector to perform
threadThe thread on which to perform the selector
objectThe object that is passed to the method specified by the selector
waitUntilDoneWhether to wait until the perform finished

◆ performSelector:onThread:withObject:withObject:afterDelay:

- (void) performSelector: (SEL) selector
onThread: (OFThread *) thread
withObject: (nullable id) object1
withObject: (nullable id) object2
afterDelay: (OFTimeInterval) delay 

Performs the specified selector on the specified thread with the specified objects after the specified delay.

Parameters
selectorThe selector to perform
threadThe thread on which to perform the selector
object1The first object that is passed to the method specified by the selector
object2The second object that is passed to the method specified by the selector
delayThe delay after which the selector will be performed

◆ performSelector:onThread:withObject:withObject:waitUntilDone:

- (void) performSelector: (SEL) selector
onThread: (OFThread *) thread
withObject: (nullable id) object1
withObject: (nullable id) object2
waitUntilDone: (bool) waitUntilDone 

Performs the specified selector on the specified thread with the specified objects.

Parameters
selectorThe selector to perform
threadThe thread on which to perform the selector
object1The first object that is passed to the method specified by the selector
object2The second object that is passed to the method specified by the selector
waitUntilDoneWhether to wait until the perform finished

◆ performSelector:onThread:withObject:withObject:withObject:afterDelay:

- (void) performSelector: (SEL) selector
onThread: (OFThread *) thread
withObject: (nullable id) object1
withObject: (nullable id) object2
withObject: (nullable id) object3
afterDelay: (OFTimeInterval) delay 

Performs the specified selector on the specified thread with the specified objects after the specified delay.

Parameters
selectorThe selector to perform
threadThe thread on which to perform the selector
object1The first object that is passed to the method specified by the selector
object2The second object that is passed to the method specified by the selector
object3The third object that is passed to the method specified by the selector
delayThe delay after which the selector will be performed

◆ performSelector:onThread:withObject:withObject:withObject:waitUntilDone:

- (void) performSelector: (SEL) selector
onThread: (OFThread *) thread
withObject: (nullable id) object1
withObject: (nullable id) object2
withObject: (nullable id) object3
waitUntilDone: (bool) waitUntilDone 

Performs the specified selector on the specified thread with the specified objects.

Parameters
selectorThe selector to perform
threadThe thread on which to perform the selector
object1The first object that is passed to the method specified by the selector
object2The second object that is passed to the method specified by the selector
object3The third object that is passed to the method specified by the selector
waitUntilDoneWhether to wait until the perform finished

◆ performSelector:onThread:withObject:withObject:withObject:withObject:afterDelay:

- (void) performSelector: (SEL) selector
onThread: (OFThread *) thread
withObject: (nullable id) object1
withObject: (nullable id) object2
withObject: (nullable id) object3
withObject: (nullable id) object4
afterDelay: (OFTimeInterval) delay 

Performs the specified selector on the specified thread with the specified objects after the specified delay.

Parameters
selectorThe selector to perform
threadThe thread on which to perform the selector
object1The first object that is passed to the method specified by the selector
object2The second object that is passed to the method specified by the selector
object3The third object that is passed to the method specified by the selector
object4The fourth object that is passed to the method specified by the selector
delayThe delay after which the selector will be performed

◆ performSelector:onThread:withObject:withObject:withObject:withObject:waitUntilDone:

- (void) performSelector: (SEL) selector
onThread: (OFThread *) thread
withObject: (nullable id) object1
withObject: (nullable id) object2
withObject: (nullable id) object3
withObject: (nullable id) object4
waitUntilDone: (bool) waitUntilDone 

Performs the specified selector on the specified thread with the specified objects.

Parameters
selectorThe selector to perform
threadThe thread on which to perform the selector
object1The first object that is passed to the method specified by the selector
object2The second object that is passed to the method specified by the selector
object3The third object that is passed to the method specified by the selector
object4The fourth object that is passed to the method specified by the selector
waitUntilDoneWhether to wait until the perform finished

◆ performSelector:withObject:afterDelay:

- (void) performSelector: (SEL) selector
withObject: (nullable id) object
afterDelay: (OFTimeInterval) delay 

Performs the specified selector with the specified object after the specified delay.

Parameters
selectorThe selector to perform
objectThe object that is passed to the method specified by the selector
delayThe delay after which the selector will be performed

◆ performSelector:withObject:withObject:afterDelay:

- (void) performSelector: (SEL) selector
withObject: (nullable id) object1
withObject: (nullable id) object2
afterDelay: (OFTimeInterval) delay 

Performs the specified selector with the specified objects after the specified delay.

Parameters
selectorThe selector to perform
object1The first object that is passed to the method specified by the selector
object2The second object that is passed to the method specified by the selector
delayThe delay after which the selector will be performed

◆ performSelector:withObject:withObject:withObject:afterDelay:

- (void) performSelector: (SEL) selector
withObject: (nullable id) object1
withObject: (nullable id) object2
withObject: (nullable id) object3
afterDelay: (OFTimeInterval) delay 

Performs the specified selector with the specified objects after the specified delay.

Parameters
selectorThe selector to perform
object1The first object that is passed to the method specified by the selector
object2The second object that is passed to the method specified by the selector
object3The third object that is passed to the method specified by the selector
delayThe delay after which the selector will be performed

◆ performSelector:withObject:withObject:withObject:withObject:afterDelay:

- (void) performSelector: (SEL) selector
withObject: (nullable id) object1
withObject: (nullable id) object2
withObject: (nullable id) object3
withObject: (nullable id) object4
afterDelay: (OFTimeInterval) delay 

Performs the specified selector with the specified objects after the specified delay.

Parameters
selectorThe selector to perform
object1The first object that is passed to the method specified by the selector
object2The second object that is passed to the method specified by the selector
object3The third object that is passed to the method specified by the selector
object4The fourth object that is passed to the method specified by the selector
delayThe delay after which the selector will be performed

◆ performSelectorOnMainThread:waitUntilDone:

- (void) performSelectorOnMainThread: (SEL) selector
waitUntilDone: (bool) waitUntilDone 

Performs the specified selector on the main thread.

Parameters
selectorThe selector to perform
waitUntilDoneWhether to wait until the perform finished

◆ performSelectorOnMainThread:withObject:waitUntilDone:

- (void) performSelectorOnMainThread: (SEL) selector
withObject: (nullable id) object
waitUntilDone: (bool) waitUntilDone 

Performs the specified selector on the main thread with the specified object.

Parameters
selectorThe selector to perform
objectThe object that is passed to the method specified by the selector
waitUntilDoneWhether to wait until the perform finished

◆ performSelectorOnMainThread:withObject:withObject:waitUntilDone:

- (void) performSelectorOnMainThread: (SEL) selector
withObject: (nullable id) object1
withObject: (nullable id) object2
waitUntilDone: (bool) waitUntilDone 

Performs the specified selector on the main thread with the specified objects.

Parameters
selectorThe selector to perform
object1The first object that is passed to the method specified by the selector
object2The second object that is passed to the method specified by the selector
waitUntilDoneWhether to wait until the perform finished

◆ performSelectorOnMainThread:withObject:withObject:withObject:waitUntilDone:

- (void) performSelectorOnMainThread: (SEL) selector
withObject: (nullable id) object1
withObject: (nullable id) object2
withObject: (nullable id) object3
waitUntilDone: (bool) waitUntilDone 

Performs the specified selector on the main thread with the specified objects.

Parameters
selectorThe selector to perform
object1The first object that is passed to the method specified by the selector
object2The second object that is passed to the method specified by the selector
object3The third object that is passed to the method specified by the selector
waitUntilDoneWhether to wait until the perform finished

◆ performSelectorOnMainThread:withObject:withObject:withObject:withObject:waitUntilDone:

- (void) performSelectorOnMainThread: (SEL) selector
withObject: (nullable id) object1
withObject: (nullable id) object2
withObject: (nullable id) object3
withObject: (nullable id) object4
waitUntilDone: (bool) waitUntilDone 

Performs the specified selector on the main thread with the specified objects.

Parameters
selectorThe selector to perform
object1The first object that is passed to the method specified by the selector
object2The second object that is passed to the method specified by the selector
object3The third object that is passed to the method specified by the selector
object4The fourth object that is passed to the method specified by the selector
waitUntilDoneWhether to wait until the perform finished

◆ replaceClassMethod:withMethodFromClass:

+ (IMP) replaceClassMethod: (SEL) selector
withMethodFromClass: (Class) class_ 

Replaces a class method with a class method from another class.

Parameters
selectorThe selector of the class method to replace
class_The class from which the new class method should be taken
Returns
The old implementation

◆ replaceInstanceMethod:withMethodFromClass:

+ (IMP) replaceInstanceMethod: (SEL) selector
withMethodFromClass: (Class) class_ 

Replaces an instance method with an instance method from another class.

Parameters
selectorThe selector of the instance method to replace
class_The class from which the new instance method should be taken
Returns
The old implementation

◆ resolveClassMethod:

+ (bool) resolveClassMethod: (SEL) selector

Try to resolve the specified class method.

This method is called if a class method was not found, so that an implementation can be provided at runtime.

Returns
Whether the method has been added to the class

◆ resolveInstanceMethod:

+ (bool) resolveInstanceMethod: (SEL) selector

Try to resolve the specified instance method.

This method is called if an instance method was not found, so that an implementation can be provided at runtime.

Returns
Whether the method has been added to the class

◆ superclass

+ (nullable Class) superclass

Returns the superclass of the class.

Returns
The superclass of the class

Reimplemented from <OFObject>.

◆ unload

+ (void) unload

A method which is called when the class is unloaded from the runtime.

Derived classes can override this to execute their own code when the class is unloaded.

Warning
This is not supported by the Apple runtime and currently only called by the ObjFW runtime when objc_deinit has been called! In the future, this might also be called by the ObjFW runtime when the class is part of a plugin that is being unloaded.

Property Documentation

◆ description

- (OFString *) description
readnonatomicassign

A description for the object.

This is used when the object is used in a format string and for debugging purposes.


The documentation for this class was generated from the following files: