picofuse-objc

Instance Methods | Class Methods | List of all members
NXObject Class Reference

The base class for objects in the Foundation framework. More...

#import <Foundation/Foundation.h>

Inheritance diagram for NXObject:
Inheritance graph
[legend]
Collaboration diagram for NXObject:
Collaboration graph
[legend]

Instance Methods

(void) - dealloc
 Frees the instance. More...
 
(NXZone *) - zone
 Returns the zone in which the instance was allocated. More...
 
(id) - retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id) - autorelease
 Releases the receiver later, when the current autorelease pool of the thread is drained. More...
 
(id) - copy
 Returns a copy which can't be changed by anything else, which the caller owns and has to release. More...
 
(uintptr_t) - hash
 Returns a number for the object, which is the same for objects which are equal by isEqual:. More...
 
(NXString *) - description
 Returns a string which describes the instance, for logging. More...
 
- Instance Methods inherited from Object
(id) - init
 Initialize the instance, after allocation. More...
 
(Class) - class
 Returns the class of the instance. More...
 
(Class) - superclass
 Returns the superclass of the instance. More...
 
(BOOL) - isEqual:
 Compares the receiver to another object for equality. More...
 
(BOOL) - isKindOfClass:
 Returns a Boolean value that indicates whether the receiver is an instance of a given class. More...
 
(BOOL) - conformsTo:
 Checks if the receiver's class conforms to a protocol. More...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL) - respondsToSelector:
 Checks if the receiver responds to a selector. More...
 

Class Methods

(id) + alloc
 Allocates a new instance in the default zone, or if there isn't one, with sys_calloc(). More...
 
(id) + allocWithZone:
 Allocates a new instance in a specific zone. More...
 
(id) + new
 Allocates and initializes a new instance, as [[cls alloc] init] does. More...
 
(NXString *) + description
 Returns the name of the class.
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. More...
 
(Class) + class
 Returns the class object. More...
 
(Class) + superclass
 Returns the superclass of the class. More...
 
(const char *) + name
 Returns the name of the class. More...
 
(BOOL) + conformsTo:
 Checks if the class conforms to a protocol. More...
 

Additional Inherited Members

- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

The base class for objects in the Foundation framework.

NXObject adds memory management to the root Object class: instances are allocated, and are freed once they've been released as many times as they've been retained.

Instances are allocated in the default zone, or if there isn't one, with sys_calloc(). See NXZone.

It has no instance variables of its own: the zone and the retain count are kept in memory just before the instance. That's because the compiler lays out constant strings, so their superclasses can't have any.

Any thread can retain, release and autorelease an object, except an NXAutoreleasePool, which is released by the thread which initialized it. See Threads and mutable objects.

Definition at line 28 of file NXObject.h.

Method Documentation

◆ alloc()

+ (id) alloc

Allocates a new instance in the default zone, or if there isn't one, with sys_calloc().

Returns
A new instance of the receiving class, or nil if the allocation failed. Its retain count is one, and its instance variables are zero.

◆ allocWithZone:()

+ (id) allocWithZone: (NXZone *)  zone

Allocates a new instance in a specific zone.

Parameters
zoneThe zone in which to allocate the new instance. If it's nil, this is the same as alloc.
Returns
A new instance of the receiving class, or nil if the allocation failed. Its retain count is one, and its instance variables are zero.

◆ autorelease()

- (id) autorelease

Releases the receiver later, when the current autorelease pool of the thread is drained.

Panics if there's no pool.

Returns
The receiver.

◆ copy()

- (id) copy

Returns a copy which can't be changed by anything else, which the caller owns and has to release.

An object which can't be changed returns itself, retained, which is what this does unless it's overridden. One which can, such as an NXMutableString or NXArray, returns a new object with the same contents, in the same zone.

Implemented in NXMap, NXArray, NXData, and NXMutableString.

◆ dealloc()

- (void) dealloc

Frees the instance.

This is called when the retain count reaches zero, and shouldn't be called otherwise. Subclasses which override it should free their own resources, and then call the superclass.

Implemented in NXZone.

◆ description()

- (NXString *) description

Returns a string which describes the instance, for logging.

Unless it's overridden, that's the name of its class.

Implemented in NXDate, NXString, NXMap, NXArray, NXNumber, NXColor, NXData, NXAtomic, and NXNull.

◆ hash()

- (uintptr_t) hash

Returns a number for the object, which is the same for objects which are equal by isEqual:.

Unless it's overridden, that's the address of the object, as objects are only equal to themselves. An object mustn't change while something depends on its hash, such as while it's a key in a map.

Implemented in NXDate, NXString, NXMap, NXArray, NXNumber, and NXData.

◆ new()

+ (id) new

Allocates and initializes a new instance, as [[cls alloc] init] does.

Returns
A new instance, which isn't autoreleased: its retain count is one. It's nil if the allocation or initialization failed.

◆ release()

- (void) release

Decreases the retain count of the receiver.

If it becomes zero, the receiver is deallocated.

◆ retain()

- (id) retain

Increases the retain count of the receiver.

Returns
The receiver, with its retain count incremented.

◆ zone()

- (NXZone *) zone

Returns the zone in which the instance was allocated.

Returns
The zone, or nil if it wasn't allocated in a zone.

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