Apple WebObjects 3.5 Manual de usuario Pagina 197

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 218
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 196
Commonly Used Array Methods
197
Creating Arrays
The methods in this section are class methods, as denoted by the plus sign
(+). You use class methods to send messages to a class—in this case,
NSArray or NSMutableArray. For more information on class methods, see
“Sending a Message to a Class” (page 172).
+ array
Returns an empty array. Usually used to create NSMutableArrays.
NSArrays created with this method are permanently empty.
// Most common use
id mutableArray = [NSMutableArray array];
// May not be what you want
id array = [NSArray array];
+ arrayWithObject:
Returns an array containing the single specified object.
+ arrayWithObjects:
Returns an array containing the objects in the argument list. The
argument list is a comma-separated list of objects ending with
nil.
id array = [NSMutableArray arrayWithObjects:
@"Plates", @"Plasticware", @"Napkins", nil];
+ arrayWithArray:
Returns an array containing the contents of a specified array.
Usually used to create an NSMutableArray from an immutable
NSArray. For example, the following statement creates an
NSMutableArray from a constant NSArray object:
id mutableArray = [NSMutableArray
arrayWithArray:@("A", "B", "C")];
+ arrayWithContentsOfFile:
Returns an array initialized from the contents of a specified file.
The specified file can be a full or relative pathname; the file that it
names must contain a string representation of an array, such as that
produced by the
writeToFile:atomically: method.
See also
description (page 200) .
Querying Arrays
– count
Returns the number of objects in the array.
Vista de pagina 196
1 2 ... 192 193 194 195 196 197 198 199 200 201 202 ... 217 218

Comentarios a estos manuales

Sin comentarios