Instance Method

URLForKey:

Returns the URL associated with the specified key.

Declaration

- (NSURL *)URLForKey:(NSString *)defaultName;

Parameters

defaultName

A key in the current user’s defaults database.

Return Value

The URL associated with the specified key. If the key doesn’t exist, this method returns nil.

Discussion

This method retrieves the URL associated with a key with the following behavior:

  1. If the value for the key is an NSData object, the data object is used as the argument to unarchiveObjectWithData:. If the data object can be unarchived as an NSURL, the URL is returned. If the URL can’t be archived as an NSURL, nil is returned.

  2. If the value for this key is a file reference URL, the file reference URL is created, but its bookmark data isn’t resolved until the NSURL object is later used (for example, with initWithContentsOfURL:).

  3. If the value for the key is a string which begins with a tilde (~), the string is expanded using the stringByExpandingTildeInPath method, from which an NSURL with the file: scheme is created.

See Also

Getting Default Values

- objectForKey:

Returns the object associated with the specified key.

- arrayForKey:

Returns the array associated with the specified key.

- dictionaryForKey:

Returns the dictionary object associated with the specified key.

- stringForKey:

Returns the string associated with the specified key.

- stringArrayForKey:

Returns the array of strings associated with the specified key.

- dataForKey:

Returns the data object associated with the specified key.

- boolForKey:

Returns the Boolean value associated with the specified key.

- integerForKey:

Returns the integer value associated with the specified key.

- floatForKey:

Returns the float value associated with the specified key.

- doubleForKey:

Returns the double value associated with the specified key.

- dictionaryRepresentation

Returns a dictionary that contains a union of all key-value pairs in the domains in the search list.