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

Overview

Loads and caches information regarding a specific stylesheet.

Use this object to load and parse a CSS stylesheet from disk and then apply the stylesheet to views. Rulesets are cached on demand and cleared when a memory warning is received.

Stylesheets can be merged using the addStylesheet: method.

Cached rulesets are released when a memory warning is received.

Tasks

(Class) + rulesetClass
 
(void) + setRulesetClass:
 
Properties
NSSet * dependencies property
 
Loading Stylesheets
(BOOL) - loadFromPath:pathPrefix:delegate:
 
(BOOL) - loadFromPath:pathPrefix:
 
(BOOL) - loadFromPath:
 
Compositing Stylesheets
(void) - addStylesheet:
 
Debugging
(NSString *) - descriptionForView:withClassName:inDOM:andViewName:
 
Applying Stylesheets to Views
(NICSSRuleset *) - rulesetForClassName:
 

Method Documentation

dependencies

A set of NSString filenames for the @imports in this stylesheet.

@property (nonatomic, readonly, copy) NSSet* dependencies;

loadFromPath:pathPrefix:delegate:

Loads and parses a CSS file from disk.

- (BOOL)loadFromPath:(NSString *)path pathPrefix:(NSString *)pathPrefix delegate:(id<NICSSParserDelegate>)delegate;
Discussion
Parameters
pathThe path of the file to be read.
pathPrefix[optional] A prefix path that will be prepended to the given path as well as any imported files.
delegate[optional] A delegate that can reprocess paths.
Returns
YES if the CSS file was successfully loaded and parsed, NO otherwise.

loadFromPath:pathPrefix:

loadFromPath:

addStylesheet:

Merge another stylesheet with this one.

- (void)addStylesheet:(NIStylesheet *)stylesheet;
Discussion

All property values in the given stylesheet will overwrite values in this stylesheet. Non-overlapping values will not be modified.

descriptionForView:withClassName:inDOM:andViewName:

Build a string describing the rules that would be applied to the view given a css class name in a DOM.

- (NSString*)descriptionForView:(UIView *)view withClassName:(NSString *)className inDOM:(NIDOM *)dom andViewName:(NSString *)viewName;
Discussion

Current implementations output Objective-C code that use viewName as the target.

rulesetForClassName:

Returns an autoreleased ruleset for the given class name.

- (NICSSRuleset*)rulesetForClassName:(NSString *)className;
Discussion
Parameters
classNameEither the view's class as a string using NSStringFromClass([view class]); or a CSS class selector such as ".myClassSelector".

rulesetClass

The class to create for rule sets.

+ (Class)rulesetClass;
Discussion

Default is NICSSRuleset

setRulesetClass:

Set the class created to hold rule sets.

+ (void)setRulesetClass:(Class)rulesetClass;
Discussion

Default is NICSSRuleset