The iOS framework that grows only as fast as its documentation
NIChameleonObserver Class Reference

Overview

An observer for the Chameleon server.

This observer connects to a Chameleon server and waits for changes in stylesheets. Once a stylesheet change has been detected, the new stylesheet is retrieved from the server and a notification is fired via NIStylesheetDidChangeNotification after the stylesheet has been reloaded.

Thanks to the use of NIOperations, the stylesheet loading and processing is accomplished on a separate thread. This means that the UI will only be notified of stylesheet changes once the request thread has successfully loaded and processed the changed stylesheet.

Inheritance diagram for NIChameleonObserver:
<NIOperationDelegate> <NICSSParserDelegate>

Tasks

(id) - initWithStylesheetCache:host:
 
(NIStylesheet *) - stylesheetForPath:
 
(void) - watchSkinChanges
 
(void) - enableBonjourDiscovery:
 
(NSString *) - cssParser:pathFromPath:
 
[NIOperationDelegate] State Changes
(void) - nimbusOperationDidStart:
 
(void) - nimbusOperationWillFinish:
 
(void) - nimbusOperationDidFinish:
 
(void) - nimbusOperationDidFail:withError:
 

Method Documentation

initWithStylesheetCache:host:

Initializes a newly allocated Chameleon observer with a given stylesheet cache and host.

- (id)initWithStylesheetCache:(NIStylesheetCache *)stylesheetCache host:(NSString *)host;

stylesheetForPath:

Returns a loaded stylesheet from the given path.

- (NIStylesheet*)stylesheetForPath:(NSString *)path;

watchSkinChanges

Begins listening to the Chameleon server for changes.

- (void)watchSkinChanges;
Discussion

When changes are detected the Chameleon observer downloads the new CSS files, reloads them, and then fires the appropriate notifications.

enableBonjourDiscovery:

Browses Bonjour for services with the given name (e.g.

- (void)enableBonjourDiscovery:(NSString *)serviceName;
Discussion

your username) and sets the host automatically.

nimbusOperationDidStart:

The operation has started executing.

- (void)nimbusOperationDidStart:(NIOperation *)operation;
Discussion

nimbusOperationWillFinish:

The operation is about to complete successfully.

- (void)nimbusOperationWillFinish:(NIOperation *)operation;
Discussion

This will not be called if the operation fails.

This will be called from within the operation's runloop and must be thread safe.

nimbusOperationDidFinish:

The operation has completed successfully.

- (void)nimbusOperationDidFinish:(NIOperation *)operation;
Discussion

This will not be called if the operation fails.

nimbusOperationDidFail:withError:

The operation failed in some way and has completed.

- (void)nimbusOperationDidFail:(NIOperation *)operation withError:(NSError *)error;
Discussion

operationDidFinish: will not be called.

cssParser:pathFromPath:

The implementor may use this method to change the filename that will be used to load the CSS file from disk.

- (NSString*)cssParser:(NICSSParser *)parser pathFromPath:(NSString *)path;
Discussion

If nil is returned then the given filename will be used.

Example: This is used by the Chameleon observer to hash filenames with md5, effectively flattening the path structure so that the files can be accessed without creating subdirectories.