Up
Authors
- Richard Frith-Macdonald
-
Copyright: (C) 2005 Free Software Foundation, Inc.
NSLocalizedString(key, comment)
Availability: OpenStep
This function (macro) is used to get the localized
translation of the string
key
.
key
is looked up in the
Localizable.strings
file for the
current language. The current language is
determined by the available languages in which
the application is translated, and by using the
NSLanguages
user defaults (which should
contain an array of the languages preferred by the
user, in order of preference).
Technically, the function works by calling
localizedStringForKey:value:table:
on
the main bundle, using @""
as value, and
nil
as the table. The
comment
is ignored when the
macro is expanded; but when we have tools which can
generate the Localizable.strings
files automatically from source code, the
comment
will be used by the
tools and added as a comment before the
string to translate. Upon finding something like
NSLocalizedString (@"My useful string",
@"My useful comment about the string");
in the source code, the tools will generate a
comment and the line
" My useful string" = "My useful string";
in the Localizable.strings
file (the
translator then can use this as a skeleton for
the Localizable.strings
for his/her own
language, where she/he can replace the right hand
side with the translation in her/his own language).
The comment can help the translator to
decide how to translate when it is not clear how to
translate (because the original string is now out
of context, and out of context might not be so clear
what the string means). The comment is
totally ignored by the library code.
If you don't have a comment (because the
string is so self-explanatory that it doesn't need
it), you can leave it blank, by using @""
as a comment. If the string might be unclear
out of context, it is recommended that you add a
comment (even if it is unused for now).
NSLocalizedStringFromTable(key, tbl, comment)
Availability: OpenStep
This function (macro) does the same as
NSLocalizedString
, but uses the table
table
rather than the default table. This
means that the string to translate will be looked up in
a different file than Localizable.strings
. For
example, if you pass DatabaseErrors
as
the table
, the string will be looked up for
translation in the file
DatabaseErrors.strings
. This allows you
to have the same string translated in different ways, by
having a different translation in different tables,
and choosing between the different translation by
choosing a different table.
NSLocalizedStringFromTableInBundle(key, tbl, bundle, comment)
Availability: OpenStep
This function is the full-blown localization function
(it is actually a macro). It looks up the string
key
for translation in the
table table
of the bundle
bundle
(please refer to the
NSBundle documentation for more information on how
this lookup is done). comment
is
a comment, which is ignored by the library (it
is discarded when the macro is expanded) but which can be
used by tools which parse the source code and generate
strings table to provide a comment which
the translator can use when translating the string.
NSAssert(condition, desc)
Availability: OpenStep
Used in an ObjC method body.
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception using
desc
NSAssert1(condition, desc, arg1)
Availability: OpenStep
Used in an ObjC method body.
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception using
desc and
arg1
NSAssert2(condition, desc, arg1, arg2)
Availability: OpenStep
Used in an ObjC method body.
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception using
desc and
arg1,
arg2
NSAssert3(condition, desc, arg1, arg2, arg3)
Availability: OpenStep
Used in an ObjC method body.
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception using
desc and
arg1,
arg2,
arg3
NSAssert4(condition, desc, arg1, arg2, arg3, arg4)
Availability: OpenStep
Used in an ObjC method body.
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception using
desc and
arg1,
arg2,
arg3,
arg4
NSAssert5(condition, desc, arg1, arg2, arg3, arg4, arg5)
Availability: OpenStep
Used in an ObjC method body.
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception using
desc and
arg1,
arg2,
arg3,
arg4,
arg5
NSCAssert(condition, desc)
Availability: OpenStep
Used in plain C code (not in an ObjC method body).
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception using
desc
NSCAssert1(condition, desc, arg1)
Availability: OpenStep
Used in plain C code (not in an ObjC method body).
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception using
desc and
arg1
NSCAssert2(condition, desc, arg1, arg2)
Availability: OpenStep
Used in plain C code (not in an ObjC method body).
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception using
desc and
arg1,
arg2
NSCAssert3(condition, desc, arg1, arg2, arg3)
Availability: OpenStep
Used in plain C code (not in an ObjC method body).
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception using
desc and
arg1,
arg2,
arg3
NSCAssert4(condition, desc, arg1, arg2, arg3, arg4)
Availability: OpenStep
Used in plain C code (not in an ObjC method body).
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception using
desc and
arg1,
arg2,
arg3,
arg4
NSCAssert5(condition, desc, arg1, arg2, arg3, arg4, arg5)
Availability: OpenStep
Used in plain C code (not in an ObjC method body).
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception using
desc and
arg1,
arg2,
arg3,
arg4,
arg5
NSCParameterAssert(condition)
Availability: OpenStep
Used in plain C code (not in an ObjC method body).
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception saying that an invalid parameter
was supplied to the method.
NSParameterAssert(condition)
Availability: OpenStep
Used in an ObjC method body.
See
NSAssertionHandler
for details.
When
condition is false,
raise an exception saying that an invalid parameter
was supplied to the method.
NS_INVOCATION(aClass, message,...)
Availability: OpenStep
Creates and returns an autoreleased invocation
containing a message to an instance of
the class. The 'message' consists of selector and
arguments like a standard ObjectiveC method call.
Before using the returned invocation, you need
to set its target.
NS_MESSAGE(target, message,...)
Availability: OpenStep
Creates and returns an autoreleased invocation
containing a message to the
target object. The 'message' consists of
selector and arguments like a standard ObjectiveC
method call.
GS_INITIALIZED_LOCK(IDENT, CLASSNAME)
Availability: Not in OpenStep/MacOS-X
Returns
IDENT which will be initialized to
an instance of a
CLASSNAME in a thread safe
manner. If
IDENT has been previously
initialized this macro merely returns
IDENT.
IDENT is considered
uninitialized, if it contains
nil
.
CLASSNAME must be either NSLock,
NSRecursiveLock or one of their subclasses.
See
[NSLock +newLockAt:]
for details. This macro is intended for code that cannot
insure that a lock can be initialized in thread safe
manner otherwise.
NSLock *my_lock = nil;
void function (void)
{
[GS_INITIALIZED_LOCK(my_lock, NSLock) lock];
do_work ();
[my_lock unlock];
}
NSBSDOperatingSystem
Availability: Not in OpenStep/MacOS-X, Base Likely to be changed/moved/removed at 1.15.0
Constants returned by the
-operatingSystem
method. NB. The presence of a constant in this list
does *NOT* imply that the named operating system is
supported. Some values are provided for MacOS-X
compatibility or are obsolete and provided for
backward compatibility.
NSBeOperatingSystem
Availability: Not in OpenStep/MacOS-X, Base Likely to be changed/moved/removed at 1.15.0
Constants returned by the
-operatingSystem
method. NB. The presence of a constant in this list
does *NOT* imply that the named operating system is
supported. Some values are provided for MacOS-X
compatibility or are obsolete and provided for
backward compatibility.
NSCygwinOperatingSystem
Availability: Not in OpenStep/MacOS-X, Base Likely to be changed/moved/removed at 1.15.0
Constants returned by the
-operatingSystem
method. NB. The presence of a constant in this list
does *NOT* imply that the named operating system is
supported. Some values are provided for MacOS-X
compatibility or are obsolete and provided for
backward compatibility.
NSGNULinuxOperatingSystem
Availability: Not in OpenStep/MacOS-X, Base Likely to be changed/moved/removed at 1.15.0
Constants returned by the
-operatingSystem
method. NB. The presence of a constant in this list
does *NOT* imply that the named operating system is
supported. Some values are provided for MacOS-X
compatibility or are obsolete and provided for
backward compatibility.
NSUncaughtExceptionHandler* NSGetUncaughtExceptionHandler();
Availability: OpenStep
Returns the exception handler called when an
exception is generated and not caught by the
programmer (by enclosing in
NS_DURING
and
NS_HANDLER
...
NS_ENDHANDLER
). The default prints an error message and exits the
program. You can change this behavior by calling
NSSetUncaughtExceptionHandler()
.
void NSSetUncaughtExceptionHandler(NSUncaughtExceptionHandler* handler);
Availability: OpenStep
Sets the exception handler called when an
exception is generated and not caught by the
programmer (by enclosing in
NS_DURING
and NS_HANDLER
... NS_ENDHANDLER
). The default prints an
error message and exits the program. proc should take
a single argument of type NSException *
.
NB. If the exception handler set by this
function does not terminate the process, the
process will be terminateed anyway. This is a
safety precaution to ensure that, in the event of an
exception being raised and not handled, the
program does not try to continue running in a
confused state (possibly doing horrible things
like billing customers who shouldn't be billed etc),
but shuts down as cleanly as possible.
Process termination is normally accomplished by
calling the standard exit function of the C runtime
library, but if the environment variable
CRASH_ON_ABORT is set to YES
or
TRUE or 1 the termination will be accomplished by
calling the abort function instead, which should
cause a core dump to be made for debugging.
The value of proc should be a pointer to a function
taking an
NSException
instance as an argument.
void NSUncaughtExceptionHandler(NSException* exception);
Availability: OpenStep
void _NSAddHandler(NSHandler* handler);
Availability: OpenStep
Private support routine. Do not call directly.
void _NSRemoveHandler(NSHandler* handler);
Availability: OpenStep
Private support routine. Do not call directly.
NSObject* NSAllocateObject(Class aClass, unsigned int extraBytes, NSZone* zone);
Availability: OpenStep
Used to allocate memory to hold an object, and
initialise the class of the object to be
aClass etc. The allocated memory will be
extraBytes larger than the space actually
needed to hold the instance variables of the object.
This function is used by the
[NSObject +allocWithZone:]
method.
NSObject* NSCopyObject(NSObject* anObject, unsigned int extraBytes, NSZone* zone);
Availability: OpenStep
Used to copy
anObject. This makes a bitwise
copy of
anObject to memory allocated from
zone. The allocated memory will be
extraBytes longer than that necessary to
actually store the instance variables of the copied
object.
This is used by the NSObject
implementation of the
[<NSCopying>-copyWithZone:]
method.
void NSDeallocateObject(NSObject* anObject);
Availability: OpenStep
Used to release the memory used by an object.
This function is used by the
[NSObject -dealloc]
method.
BOOL NSDecrementExtraRefCountWasZero(id anObject);
Availability: OpenStep
Description forthcoming.
unsigned int NSExtraRefCount(id anObject);
Availability: OpenStep
Return the extra reference count of
anObject (a value in the range from 0 to the
maximum unsigned integer value minus
one).
The retain count for an object is this
value plus one.
void NSIncrementExtraRefCount(id anObject);
Availability: OpenStep
Increments the extra reference count for
anObject.
The GNUstep version raises
an exception if the reference count would be incremented
to too large a value.
This is used by the
[NSObject -retain]
method.
BOOL NSShouldRetainWithZone(NSObject* anObject, NSZone* requestedZone);
Availability: OpenStep
Returns a flag to indicate whether
anObject should be retained or copied in
order to make a copy in the specified zone.
Basically, this tests to see if
anObject was allocated from
requestedZone and returns YES
if it was.
BOOL GSDebugSet(NSString* level);
Availability: Base
Likely to be changed/moved/removed at 1.17.0
Function for rapid testing to see if a debug
level is set.
This is used by the
debugging macros.
If debug logging has been
turned off, this returns NO
even if the
specified level exists in the set of
debug levels.
void GSUPurge(unsigned int count);
Availability: Not in OpenStep/MacOS-X
This function purges the global
NSCountedSet
object used for uniquing. It handles locking as
necessary. It can be used to purge the set even
when uniquing is turned off.
id GSUSet(id anObject, unsigned int count);
Availability: Not in OpenStep/MacOS-X
This function sets the count for the
specified object. If the count for the
object is set to zero then the object is removed from
the global uniquing set. The object is added to the set
if necessary. The object returned is the one stored in the
set. The function handles locking as necessary. It can
be used to alter the set even when uniquing is turned off.
id GSUnique(id anObject);
Availability: Not in OpenStep/MacOS-X
This function
uniques the supplied argument,
returning the result. It works by using the
[-unique:]
method of a global NSCountedSet object. It handles
locking as necessary. If uniquing is turned off, it
simply returns its argument.
void GSUniquing(BOOL flag);
Availability: Not in OpenStep/MacOS-X
This function sets the state of a
flag that
determines the behavior of the
GSUnique()
function. If the
flag is on, uniquing is
performed, if it is off the function has no
effect. The default is for uniquing to be turned off.
NSThread* GSCurrentThread();
Availability: Base
Likely to be changed/moved/removed at 0.0.0
This function is a GNUstep extension. It pretty much
duplicates the functionality of [NSThread
+currentThread] but is more efficient and
is used internally throughout GNUstep.
Returns the current thread. Could perhaps return
nil
if executing a thread that was
started outside the GNUstep environment and not
registered (this should not happen in a
well-coded application).
NSMutableDictionary* GSCurrentThreadDictionary();
Availability: Base
Likely to be changed/moved/removed at 0.0.0
Fast access function for thread dictionary of current
thread.
BOOL GSRegisterCurrentThread();
Availability: Base
Likely to be changed/moved/removed at 0.0.0
This function is provided to let threads started by
some other software library register themselves to be
used with the GNUstep system. All such threads should
call this function before attempting to use any
GNUstep objects.
Returns YES
if the thread can be
registered, NO
if it is already
registered.
Sends out a
NSWillBecomeMultiThreadedNotification
if the process was not already multithreaded.
void GSUnregisterCurrentThread();
Availability: Base
Likely to be changed/moved/removed at 0.0.0
This function is provided to let threads started by
some other software library unregister themselves from
the GNUstep threading system.
Calling this function causes a
NSThreadWillExitNotification
to be sent
out, and destroys the GNUstep NSThread object
associated with the thread.
Up