ObjFW
|
The root class for all other classes inside ObjFW. More...
#import <ObjFW/OFObject.h>
Instance Methods | |
(id) | - init |
Initializes an already allocated object. More... | |
(OFString *) | - className |
Returns the name of the object's class. More... | |
(OFString *) | - description |
Returns a description for the object. More... | |
(void *) | - allocMemoryWithSize: |
Allocates memory and stores it in the object's memory pool. More... | |
(void *) | - allocMemoryWithSize:count: |
Allocates memory for the specified number of items and stores it in the object's memory pool. More... | |
(nullable void *) | - resizeMemory:size: |
Resizes memory in the object's memory pool to the specified size. More... | |
(nullable void *) | - resizeMemory:size:count: |
Resizes memory in the object's memory pool to the specific number of items of the specified size. More... | |
(void) | - freeMemory: |
Frees allocated memory and removes it from the object's memory pool. More... | |
(void) | - dealloc |
Deallocates the object. More... | |
(void) | - performSelector:afterDelay: |
Performs the specified selector after the specified delay. More... | |
(void) | - performSelector:withObject:afterDelay: |
Performs the specified selector with the specified object after the specified delay. More... | |
(void) | - performSelector:withObject:withObject:afterDelay: |
Performs the specified selector with the specified objects after the specified delay. More... | |
(void) | - performSelector:onThread:waitUntilDone: |
Performs the specified selector on the specified thread. More... | |
(void) | - performSelector:onThread:withObject:waitUntilDone: |
Performs the specified selector on the specified thread with the specified object. More... | |
(void) | - performSelector:onThread:withObject:withObject:waitUntilDone: |
Performs the specified selector on the specified thread with the specified objects. More... | |
(void) | - performSelectorOnMainThread:waitUntilDone: |
Performs the specified selector on the main thread. More... | |
(void) | - performSelectorOnMainThread:withObject:waitUntilDone: |
Performs the specified selector on the main thread with the specified object. More... | |
(void) | - performSelectorOnMainThread:withObject:withObject:waitUntilDone: |
Performs the specified selector on the main thread with the specified objects. More... | |
(void) | - performSelector:onThread:afterDelay: |
Performs the specified selector on the specified thread after the specified delay. More... | |
(void) | - performSelector:onThread:withObject:afterDelay: |
Performs the specified selector on the specified thread with the specified object after the specified delay. More... | |
(void) | - performSelector:onThread:withObject:withObject:afterDelay: |
Performs the specified selector on the specified thread with the specified objects after the specified delay. More... | |
(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. More... | |
(void) | - doesNotRecognizeSelector: |
Handles messages which are not understood by the receiver. More... | |
(OFString *) | - stringBySerializing |
Creates a string by serializing the receiver. More... | |
Instance Methods inherited from <OFObject> | |
(bool) | - isKindOfClass: |
Returns a boolean whether the object of the specified kind. More... | |
(bool) | - isMemberOfClass: |
Returns a boolean whether the object is a member of the specified class. More... | |
(bool) | - respondsToSelector: |
Returns a boolean whether the object responds to the specified selector. More... | |
(nullable IMP) | - methodForSelector: |
Returns the implementation for the specified selector. More... | |
(nullable const char *) | - typeEncodingForSelector: |
Returns the type encoding for the specified selector. More... | |
(nullable id) | - performSelector: |
Performs the specified selector. More... | |
(nullable id) | - performSelector:withObject: |
Performs the specified selector with the specified object. More... | |
(nullable id) | - performSelector:withObject:withObject: |
Performs the specified selector with the specified objects. More... | |
(bool) | - isEqual: |
Checks two objects for equality. More... | |
(uint32_t) | - hash |
Calculates a hash for the object. More... | |
(id) | - retain |
Increases the retain count. More... | |
(unsigned int) | - retainCount |
Returns the retain count. More... | |
(void) | - release |
Decreases the retain count. More... | |
(id) | - autorelease |
Adds the object to the topmost OFAutoreleasePool of the thread's autorelease pool stack. More... | |
(id) | - self |
Returns the receiver. More... | |
(bool) | - isProxy |
Returns whether the object is a proxy object. More... | |
Class Methods | |
(void) | + load |
A method which is called once when the class is loaded into the runtime. More... | |
(void) | + unload |
A method which is called when the class is unloaded from the runtime. More... | |
(void) | + initialize |
A method which is called the moment before the first call to the class is being made. More... | |
(id) | + alloc |
Allocates memory for an instance of the class and sets up the memory pool for the object. More... | |
(id) | + new |
Allocates memory for a new instance and calls init on it. More... | |
(Class) | + class |
Returns the class. More... | |
(OFString *) | + className |
Returns the name of the class as a string. More... | |
(bool) | + isSubclassOfClass: |
Returns a boolean whether the class is a subclass of the specified class. More... | |
(Class) | + superclass |
Returns the superclass of the class. More... | |
(bool) | + instancesRespondToSelector: |
Checks whether instances of the class respond to a given selector. More... | |
(bool) | + conformsToProtocol: |
Checks whether the class conforms to a given protocol. More... | |
(nullable IMP) | + instanceMethodForSelector: |
Returns the implementation of the instance method for the specified selector. More... | |
(nullable const char *) | + typeEncodingForInstanceSelector: |
Returns the type encoding of the instance method for the specified selector. More... | |
(OFString *) | + description |
Returns a description for the class, which is usually the class name. More... | |
(nullable IMP) | + replaceClassMethod:withMethodFromClass: |
Replaces a class method with a class method from another class. More... | |
(nullable IMP) | + replaceInstanceMethod:withMethodFromClass: |
Replaces an instance method with an instance method from another class. More... | |
(nullable IMP) | + replaceClassMethod:withImplementation:typeEncoding: |
Replaces or adds a class method. More... | |
(nullable IMP) | + replaceInstanceMethod:withImplementation:typeEncoding: |
Replaces or adds an instance method. More... | |
(void) | + inheritMethodsFromClass: |
Adds all methods from the specified class to the class that is the receiver. More... | |
(bool) | + resolveClassMethod: |
Try to resolve the specified class method. More... | |
(bool) | + resolveInstanceMethod: |
Try to resolve the specified instance method. More... | |
(id) | + copy |
Returns the class. More... | |
The root class for all other classes inside ObjFW.
+ (id) alloc |
Allocates memory for an instance of the class and sets up the memory pool for the object.
This method will never return nil, instead, it will throw an OFAllocFailedException.
- (void *) allocMemoryWithSize: | (size_t) | size |
Allocates memory and stores it in the object's memory pool.
It will be free'd automatically when the object is deallocated.
size | The size of the memory to allocate |
- (void *) allocMemoryWithSize: | (size_t) | size | |
count: | (size_t) | count | |
Allocates memory for the specified number of items and stores it in the object's memory pool.
It will be free'd automatically when the object is deallocated.
size | The size of each item to allocate |
count | The number of items to allocate |
+ (Class) class |
- (OFString*) className |
Returns the name of the object's class.
+ (OFString *) className |
Returns the name of the class as a string.
+ (bool) conformsToProtocol: | (Protocol*) | protocol |
Checks whether the class conforms to a given protocol.
protocol | The protocol which should be checked for conformance |
Reimplemented from <OFObject>.
+ (id) copy |
Returns the class.
This method exists so that classes can be used in collections requiring conformance to the OFCopying protocol.
- (void) dealloc |
Deallocates the object.
It is automatically called when the retain count reaches zero.
This also frees all memory in its memory pool.
- (OFString*) description |
Returns a description for the object.
This is mostly for debugging purposes.
Reimplemented in OFException, and OFAllocFailedException.
+ (OFString *) description |
Returns a description for the class, which is usually the class name.
This is mostly for debugging purposes.
Reimplemented in OFException, and OFAllocFailedException.
- (void) doesNotRecognizeSelector: | (SEL) | selector |
Handles messages which are not understood by the receiver.
selector | The selector not understood by the receiver |
- (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.
- (void) freeMemory: | (nullable void *) | pointer |
Frees allocated memory and removes it from the object's memory pool.
Does nothing if the pointer is NULL.
pointer | A pointer to the allocated memory |
+ (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.
class_ | The class from which the instance methods should be inherited |
- (id) init |
Initializes an already allocated object.
Derived classes may override this, but need to do
before they do any initialization themselves. init may never return nil, instead an exception (for example OFInitializationFailedException) should be thrown.
+ (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.
+ (IMP) instanceMethodForSelector: | (SEL) | selector |
Returns the implementation of the instance method for the specified selector.
selector | The selector for which the method should be returned |
+ (bool) instancesRespondToSelector: | (SEL) | selector |
Checks whether instances of the class respond to a given selector.
selector | The selector which should be checked for respondance |
+ (bool) isSubclassOfClass: | (Class) | class_ |
Returns a boolean whether the class is a subclass of the specified class.
class_ | The class which is checked for being a superclass |
+ (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.
+ (id) new |
Allocates memory for a new instance and calls init on it.
- (void) performSelector: | (SEL) | selector | |
afterDelay: | (of_time_interval_t) | delay | |
Performs the specified selector after the specified delay.
selector | The selector to perform |
delay | The delay after which the selector will be performed |
- (void) performSelector: | (SEL) | selector | |
onThread: | (OFThread*) | thread | |
afterDelay: | (of_time_interval_t) | delay | |
Performs the specified selector on the specified thread after the specified delay.
selector | The selector to perform |
thread | The thread on which to perform the selector |
delay | The delay after which the selector will be performed |
- (void) performSelector: | (SEL) | selector | |
onThread: | (OFThread*) | thread | |
waitUntilDone: | (bool) | waitUntilDone | |
Performs the specified selector on the specified thread.
selector | The selector to perform |
thread | The thread on which to perform the selector |
waitUntilDone | Whether to wait until the perform finished |
- (void) performSelector: | (SEL) | selector | |
onThread: | (OFThread *) | thread | |
withObject: | (nullable id) | object | |
afterDelay: | (of_time_interval_t) | delay | |
Performs the specified selector on the specified thread with the specified object after the specified delay.
selector | The selector to perform |
thread | The thread on which to perform the selector |
object | The object that is passed to the method specified by the selector |
delay | The delay after which the selector will be performed |
- (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.
selector | The selector to perform |
thread | The thread on which to perform the selector |
object | The object that is passed to the method specified by the selector |
waitUntilDone | Whether to wait until the perform finished |
- (void) performSelector: | (SEL) | selector | |
onThread: | (OFThread *) | thread | |
withObject: | (nullable id) | object1 | |
withObject: | (nullable id) | object2 | |
afterDelay: | (of_time_interval_t) | delay | |
Performs the specified selector on the specified thread with the specified objects after the specified delay.
selector | The selector to perform |
thread | The thread on which to perform the selector |
object1 | The first object that is passed to the method specified by the selector |
object2 | The second object that is passed to the method specified by the selector |
delay | The delay after which the selector will be performed |
- (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.
selector | The selector to perform |
thread | The thread on which to perform the selector |
object1 | The first object that is passed to the method specified by the selector |
object2 | The second object that is passed to the method specified by the selector |
waitUntilDone | Whether to wait until the perform finished |
- (void) performSelector: | (SEL) | selector | |
withObject: | (nullable id) | object | |
afterDelay: | (of_time_interval_t) | delay | |
Performs the specified selector with the specified object after the specified delay.
selector | The selector to perform |
object | The object that is passed to the method specified by the selector |
delay | The delay after which the selector will be performed |
- (void) performSelector: | (SEL) | selector | |
withObject: | (nullable id) | object1 | |
withObject: | (nullable id) | object2 | |
afterDelay: | (of_time_interval_t) | delay | |
Performs the specified selector with the specified objects after the specified delay.
selector | The selector to perform |
object1 | The first object that is passed to the method specified by the selector |
object2 | The second object that is passed to the method specified by the selector |
delay | The delay after which the selector will be performed |
- (void) performSelectorOnMainThread: | (SEL) | selector | |
waitUntilDone: | (bool) | waitUntilDone | |
Performs the specified selector on the main thread.
selector | The selector to perform |
waitUntilDone | Whether to wait until the perform finished |
- (void) performSelectorOnMainThread: | (SEL) | selector | |
withObject: | (nullable id) | object | |
waitUntilDone: | (bool) | waitUntilDone | |
Performs the specified selector on the main thread with the specified object.
selector | The selector to perform |
object | The object that is passed to the method specified by the selector |
waitUntilDone | Whether to wait until the perform finished |
- (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.
selector | The selector to perform |
object1 | The first object that is passed to the method specified by the selector |
object2 | The second object that is passed to the method specified by the selector |
waitUntilDone | Whether to wait until the perform finished |
+ (IMP) replaceClassMethod: | (SEL) | selector | |
withImplementation: | (IMP) | implementation | |
typeEncoding: | (const char*) | typeEncoding | |
Replaces or adds a class method.
If the method already exists, it is replaced and the old implementation returned. If the method does not exist, it is added with the specified type encoding.
selector | The selector for the new method |
implementation | The implementation for the new method |
typeEncoding | The type encoding for the new method |
+ (IMP) replaceClassMethod: | (SEL) | selector | |
withMethodFromClass: | (Class) | class_ | |
Replaces a class method with a class method from another class.
selector | The selector of the class method to replace |
class_ | The class from which the new class method should be taken |
+ (IMP) replaceInstanceMethod: | (SEL) | selector | |
withImplementation: | (IMP) | implementation | |
typeEncoding: | (const char*) | typeEncoding | |
Replaces or adds an instance method.
If the method already exists, it is replaced and the old implementation returned. If the method does not exist, it is added with the specified type encoding.
selector | The selector for the new method |
implementation | The implementation for the new method |
typeEncoding | The type encoding for the new method |
+ (IMP) replaceInstanceMethod: | (SEL) | selector | |
withMethodFromClass: | (Class) | class_ | |
Replaces an instance method with an instance method from another class.
selector | The selector of the instance method to replace |
class_ | The class from which the new instance method should be taken |
- (nullable void*) resizeMemory: | (nullable void *) | pointer | |
size: | (size_t) | size | |
Resizes memory in the object's memory pool to the specified size.
If the pointer is NULL, this is equivalent to allocating memory. If the size is 0, this is equivalent to freeing memory.
pointer | A pointer to the already allocated memory |
size | The new size for the memory chunk |
- (nullable void*) resizeMemory: | (nullable void *) | pointer | |
size: | (size_t) | size | |
count: | (size_t) | count | |
Resizes memory in the object's memory pool to the specific number of items of the specified size.
If the pointer is NULL, this is equivalent to allocating memory. If the size or number of items is 0, this is equivalent to freeing memory.
pointer | A pointer to the already allocated memory |
size | The size of each item to resize to |
count | The number of items to resize to |
+ (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.
+ (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.
- (OFString*) stringBySerializing |
Creates a string by serializing the receiver.
+ (Class) superclass |
Returns the superclass of the class.
Reimplemented from <OFObject>.
+ (const char *) typeEncodingForInstanceSelector: | (SEL) | selector |
Returns the type encoding of the instance method for the specified selector.
selector | The selector for which the type encoding should be returned |
+ (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.