70 id _representedObject;
99 - (id)initWithCibName:(
CPString)aCibNameOrNil bundle:(
CPBundle)aCibBundleOrNil owner:(
id)anOwner
101 return [
self initWithCibName:aCibNameOrNil bundle:aCibBundleOrNil externalNameTable:@{ CPCibOwner: anOwner }];
124 _cibName = aCibNameOrNil;
126 _cibExternalNameTable = anExternalNameTable || @{
CPCibOwner:
self };
160 var cib = [CPViewControllerCachedCibs objectForKey:_cibName];
166 [CPViewControllerCachedCibs setObject:cib forKey:_cibName];
169 [cib instantiateCibWithExternalNameTable:_cibExternalNameTable];
184 - (void)loadViewWithCompletionHandler:(Function)aHandler
192 var cib = [CPViewControllerCachedCibs objectForKey:_cibName];
198 if (![cibName hasSuffix:
@".cib"])
199 cibName = [cibName stringByAppendingString:@".cib"];
203 url = [bundle _cibPathForResource:cibName];
211 aCib = [[
CPCib alloc] _initWithData:data bundle:_cibBundle cibName:_cibName];
213 [CPViewControllerCachedCibs setObject:aCib forKey:_cibName];
214 [aCib instantiateCibWithExternalNameTable:_cibExternalNameTable];
215 aHandler(_view, nil);
219 aHandler(nil, anError);
225 [cib instantiateCibWithExternalNameTable:_cibExternalNameTable];
226 aHandler(_view, nil);
232 aHandler(_view, nil);
249 var cibOwner = [_cibExternalNameTable objectForKey:CPCibOwner];
251 if ([cibOwner respondsToSelector:
@selector(viewControllerWillLoadCib:)])
252 [cibOwner viewControllerWillLoadCib:self];
256 if (_view === nil && [cibOwner isKindOfClass:[
CPDocument class]])
257 [
self setView:[cibOwner valueForKey:@"view"]];
261 var reason = [
CPString stringWithFormat:@"View for %@ could not be loaded from Cib or no view specified. Override loadView to load the view manually.", self];
266 if ([cibOwner respondsToSelector:
@selector(viewControllerDidLoadCib:)])
267 [cibOwner viewControllerDidLoadCib:self];
314 var willChangeIsViewLoaded = (_isViewLoaded == NO && aView != nil) || (_isViewLoaded == YES && aView == nil);
316 if (willChangeIsViewLoaded)
320 _isViewLoaded = aView !== nil;
322 if (willChangeIsViewLoaded)
352 _view = [aCoder decodeObjectForKey:CPViewControllerViewKey];
353 _title = [aCoder decodeObjectForKey:CPViewControllerTitleKey];
354 _cibName = [aCoder decodeObjectForKey:CPViewControllerCibNameKey];
356 var bundlePath = [aCoder decodeObjectForKey:CPViewControllerBundleKey];
359 _cibExternalNameTable = @{
CPCibOwner:
self };
374 [aCoder encodeObject:_view forKey:CPViewControllerViewKey];
375 [aCoder encodeObject:_title forKey:CPViewControllerTitleKey];
376 [aCoder encodeObject:_cibName forKey:CPViewControllerCibNameKey];
377 [aCoder encodeObject:[_cibBundle bundlePath] forKey:CPViewControllerBundleKey];
405 return _isViewLoaded;
413 return _representedObject;
419 - (void)setRepresentedObject:(
id)aValue
421 _representedObject = aValue;
461 return _cibExternalNameTable;
Used to implement exception handling (creating & raising).
id initWithCoder:(CPCoder aCoder)
void willChangeValueForKey:(CPString aKey)
CPDictionary cibExternalNameTable()
A Cappuccino wrapper for any data type.
void raise:reason:(CPString aName, [reason] CPString aReason)
Provides loading of a URL request.
var CPViewControllerViewKey
void encodeWithCoder:(CPCoder aCoder)
A mutable key-value pair collection.
id requestWithURL:(CPURL aURL)
var CPViewControllerBundleKey
global CPApp var CPViewControllerCachedCibs
An immutable string (collection of characters).
void setView:(CPView aView)
CPData dataWithRawString:(CPString aString)
CPOperationQueue mainQueue()
void didChangeValueForKey:(CPString aKey)
CPURLConnection sendAsynchronousRequest:queue:completionHandler:(CPURLRequest aRequest, [queue] CPOperationQueue aQueue, [completionHandler] Function aHandler)
Defines methods for use when archiving & restoring (enc/decoding).
BOOL automaticallyNotifiesObserversOfIsViewLoaded()
CPBundle bundleWithPath:(CPString aPath)
id stringWithFormat:(CPString format, [,]...)
Contains data obtained during a request made with CPURLConnection.
id initWithCibName:bundle:externalNameTable:(CPString aCibNameOrNil, [bundle] CPBundle aCibBundleOrNil, [externalNameTable] CPDictionary anExternalNameTable)
id initWithCibName:bundle:(CPString aCibNameOrNil, [bundle] CPBundle aCibBundleOrNil)
var CPViewControllerCibNameKey
var CPViewControllerTitleKey
id initWithCibNamed:bundle:(CPString aName, [bundle] CPBundle aBundle)
Represents an operation queue that can run CPOperations.