Apple WebObjects 3.5 Uživatelský manuál Strana 202

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 218
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 201
Chapter 11 WebScript Programmer’s Quick Reference to Foundation Classes
202
Creating Dictionaries
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, NSDictionary
and NSMutableDictionary. For more information on class methods, see
“Sending a Message to a Class” (page 172).
+ dictionary
Returns an empty dictionary. Usually used to create
NSMutableDictionaries. NSDictionaries created with this method are
permanently empty.
// Most common use
id mutableDictionary = [NSMutableDictionary dictionary];
// May not be what you want
id dictionary = [NSDictionary dictionary];
+ dictionaryWithObjects:forKeys:
Returns a dictionary containing entries constructed from the contents
of a specified array of objects and a specified array of keys. The two
arrays must have the same number of elements.
id preferences = [NSMutableDictionary
dictionaryWithObjects:@("window", "non-smoking", "747")
forKeys:@("seatAssignment", "smoking", "aircraft")];
+ dictionaryWithObjectsAndKeys:
Returns a dictionary containing entries constructed from a specified set
of objects and keys. This method takes a variable number of
arguments: a list of alternating objects and keys ending with
nil.
id customerPreferences = [NSDictionary dictionaryWithObjectsAndKeys:
seatingPreference, @"seatAssignment",
smokingPreference, @"smoking",
aircraftPreference, @"aircraft", nil];
+ dictionaryWithDictionary:
Returns a dictionary containing the contents of a specified dictionary.
Usually used to create an NSMutableDictionary from an immutable
NSDictionary.
+ dictionaryWithContentsOfFile:
Returns a dictionary 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 a dictionary, such as that
produced by the
writeToFile:atomically: method.
See also
description (page 205) .
Zobrazit stránku 201
1 2 ... 197 198 199 200 201 202 203 204 205 206 207 ... 217 218

Komentáře k této Příručce

Žádné komentáře