Skip to content

Commit

Permalink
Fix up examples and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmoon committed Jun 26, 2020
1 parent 2cbdf05 commit d3949e8
Show file tree
Hide file tree
Showing 43 changed files with 66 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
title: ASViewController
title: ASDKViewController
layout: docs
permalink: /docs/asviewcontroller.html
permalink: /docs/ASDKViewController.html
prevPage:
nextPage: aspagernode.html
---

`ASViewController` is a direct subclass of `UIViewController`. For the most part, it can be used in place of any `UIViewController` relatively easily.
`ASDKViewController` is a direct subclass of `UIViewController`. For the most part, it can be used in place of any `UIViewController` relatively easily.

The main difference is that you construct and return the node you'd like managed as opposed to the way `UIViewController` provides a view of its own.

Consider the following `ASViewController` subclass that would like to use a custom table node as its managed node.
Consider the following `ASDKViewController` subclass that would like to use a custom table node as its managed node.

<div class = "highlight-group">
<span class="language-toggle"><a data-lang="swift" class="swiftButton">Swift</a><a data-lang="objective-c" class = "active objcButton">Objective-C</a></span>
Expand Down Expand Up @@ -52,4 +52,4 @@ The most important line is:

`if (!(self = [super initWithNode:tableNode])) { return nil; }`

As you can see, `ASViewController`'s are initialized with a node of your choosing.
As you can see, `ASDKViewController`'s are initialized with a node of your choosing.
2 changes: 1 addition & 1 deletion docs/_docs/development/layout-specs.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ This is the function that will recursively call through its underlying tree of n

![layoutcallstack1](/static/images/development/layoutspecs1.png)

This is what a typical call stack will look like for the layout of an `ASViewController` with a simple view hierarchy. Here we clicked on the "Photo with outset icon overlay" in the Layout Specs Examples project. Breakpointing on the `-[PhotoWithOutsetIconOverlay layoutSpecThatFits:]` reveals that call stack.
This is what a typical call stack will look like for the layout of an `ASDKViewController` with a simple view hierarchy. Here we clicked on the "Photo with outset icon overlay" in the Layout Specs Examples project. Breakpointing on the `-[PhotoWithOutsetIconOverlay layoutSpecThatFits:]` reveals that call stack.

The first significant branch of logic is the top level `-[ASDisplayNode calculateLayoutThatFits]` where it will choose between the Texture Layout and the Yoga engine.

Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/development/node-lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ As mentioned above, ASDeallocQueue helps to defer the deallocation of objects gi

# Nodes that are not managed by containers

These are nodes that are often directly created by client code, such as direct and indirect subnodes of cell nodes. When a node is added to a parent node, the parent node retains it until it's removed from the parent node, or until the parent node is deallocated. As a result, if the subnode is not retained by client code in any other way or if it's not removed from the parent node, the subnode's lifecycle is tied to the parent node's lifecycle. In addition, since nodes often live in a hierarchy, the entire node hierarchy has the same lifecycle as the root node's. Lastly, if the root node is managed by a node container -- directly in the case of ASViewController and the like, or indirectly as a cell node of a collection or table node --, then the entire node hierarchy is managed by the node container.
These are nodes that are often directly created by client code, such as direct and indirect subnodes of cell nodes. When a node is added to a parent node, the parent node retains it until it's removed from the parent node, or until the parent node is deallocated. As a result, if the subnode is not retained by client code in any other way or if it's not removed from the parent node, the subnode's lifecycle is tied to the parent node's lifecycle. In addition, since nodes often live in a hierarchy, the entire node hierarchy has the same lifecycle as the root node's. Lastly, if the root node is managed by a node container -- directly in the case of ASDKViewController and the like, or indirectly as a cell node of a collection or table node --, then the entire node hierarchy is managed by the node container.

## Node lifecycle under [Automatic Subnode Management (ASM)](/docs/automatic-subnode-mgmt.html)

Expand Down
18 changes: 9 additions & 9 deletions docs/_docs/subclassing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ permalink: /docs/subclassing.html
prevPage: node-overview.html
nextPage: faq.html
---
The most important distinction when creating a subclass is whether you writing an ASViewController or an ASDisplayNode. This sounds obvious, but because some of these differences are subtle, it is important to keep this top of mind.
The most important distinction when creating a subclass is whether you writing an ASDKViewController or an ASDisplayNode. This sounds obvious, but because some of these differences are subtle, it is important to keep this top of mind.

## ASDisplayNode
<br>
Expand Down Expand Up @@ -43,17 +43,17 @@ One great use of `-layout` is for the specific case in which you want a subnode
subnode.frame = self.bounds;
```

If you desire the same effect in a ASViewController, you can do the same thing in -viewWillLayoutSubviews, unless your node is the node in initWithNode: and in that case it will do this automatically.
If you desire the same effect in a ASDKViewController, you can do the same thing in -viewWillLayoutSubviews, unless your node is the node in initWithNode: and in that case it will do this automatically.

## ASViewController
## ASDKViewController
<br>
An `ASViewController` is a regular `UIViewController` subclass that has special features to manage nodes. Since it is a UIViewController subclass, all methods are called on the **main thread** (and you should always create an ASViewController on the main thread).
An `ASDKViewController` is a regular `UIViewController` subclass that has special features to manage nodes. Since it is a UIViewController subclass, all methods are called on the **main thread** (and you should always create an ASDKViewController on the main thread).

### `-init`

This method is called once, at the very beginning of an ASViewController's lifecycle. As with UIViewController initialization, it is best practice to **never access** `self.view` or `self.node.view` in this method as it will force the view to be created early. Instead, do any view access in -viewDidLoad.
This method is called once, at the very beginning of an ASDKViewController's lifecycle. As with UIViewController initialization, it is best practice to **never access** `self.view` or `self.node.view` in this method as it will force the view to be created early. Instead, do any view access in -viewDidLoad.

ASViewController's designated initializer is `initWithNode:`. A typical initializer will look something like the code below. Note how the ASViewController's node is created _before_ calling super. An ASViewController manages a node similarly to how a UIViewController manages a view, but the initialization is slightly different.
ASDKViewController's designated initializer is `initWithNode:`. A typical initializer will look something like the code below. Note how the ASDKViewController's node is created _before_ calling super. An ASDKViewController manages a node similarly to how a UIViewController manages a view, but the initialization is slightly different.


<div class = "highlight-group">
Expand Down Expand Up @@ -93,18 +93,18 @@ We recommend that you do not use this method because it is has no particular adv

### `-viewDidLoad`

This method is called once in a ASViewController's lifecycle, immediately after `-loadView`. This is the earliest time at which you should access the node's view. It is a great spot to put any **setup code that should only be run once and requires access to the view/layer**, such as adding a gesture recognizer.
This method is called once in a ASDKViewController's lifecycle, immediately after `-loadView`. This is the earliest time at which you should access the node's view. It is a great spot to put any **setup code that should only be run once and requires access to the view/layer**, such as adding a gesture recognizer.

Layout code should never be put in this method, because it will not be called again when geometry changes. Note this is equally true for UIViewController; it is bad practice to put layout code in this method even if you don't currently expect geometry changes.

### `-viewWillLayoutSubviews`

This method is called at the exact same time as a node's `-layout` method and it may be called multiple times in a ASViewController's lifecycle; it will be called whenever the bounds of the ASViewController's node are changed (including rotation, split screen, keyboard presentation) as well as when there are changes to the hierarchy (children being added, removed, or changed in size).
This method is called at the exact same time as a node's `-layout` method and it may be called multiple times in a ASDKViewController's lifecycle; it will be called whenever the bounds of the ASDKViewController's node are changed (including rotation, split screen, keyboard presentation) as well as when there are changes to the hierarchy (children being added, removed, or changed in size).

For consistency, it is best practice to put all layout code in this method. Because it is not called very frequently, even code that does not directly depend on the size belongs here.

### `-viewWillAppear:` / `-viewDidDisappear:`

These methods are called just before the ASViewController's node appears on screen (the earliest time that it is visible) and just after it is removed from the view hierarchy (the earliest time that it is no longer visible). These methods provide a good opportunity to start or stop animations related to the presentation or dismissal of your controller. This is also a good place to make a log of a user action.
These methods are called just before the ASDKViewController's node appears on screen (the earliest time that it is visible) and just after it is removed from the view hierarchy (the earliest time that it is no longer visible). These methods provide a good opportunity to start or stop animations related to the presentation or dismissal of your controller. This is also a good place to make a log of a user action.

Although these methods may be called multiple times and geometry information is available, they are not called for all geometry changes and so should not be used for core layout code (beyond setup required for specific animations).
4 changes: 2 additions & 2 deletions docs/_docs/synchronous-concurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ prevPage: subtree-rasterization.html
nextPage: corner-rounding.html
---

Both `ASViewController` and `ASCellNode` have a property called `neverShowPlaceholders`.
Both `ASDKViewController` and `ASCellNode` have a property called `neverShowPlaceholders`.

By setting this property to YES, the main thread will be blocked until display has completed for the cell or view controller's view.

Expand All @@ -27,6 +27,6 @@ node.neverShowPlaceholders = true
</div>
<br>

Usually, if a cell hasn't finished its display pass before it has reached the screen it will show placeholders until it has drawing its content. Setting this option to YES makes your scrolling node or ASViewController act more like UIKit, and in fact makes Texture scrolling visually indistinguishable from UIKit's, except that it's faster.
Usually, if a cell hasn't finished its display pass before it has reached the screen it will show placeholders until it has drawing its content. Setting this option to YES makes your scrolling node or ASDKViewController act more like UIKit, and in fact makes Texture scrolling visually indistinguishable from UIKit's, except that it's faster.

<img src="/static/images/synchronous-concurrency.jpg" width="50%">
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#import <AsyncDisplayKit/AsyncDisplayKit.h>

@interface VideoFeedNodeController : ASViewController
@interface VideoFeedNodeController : ASDKViewController

@end
2 changes: 1 addition & 1 deletion examples/ASDKTube/Sample/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#import <AsyncDisplayKit/AsyncDisplayKit.h>

@interface ViewController : ASViewController
@interface ViewController : ASDKViewController

@end
2 changes: 1 addition & 1 deletion examples/ASDKgram/Sample/PhotoFeedBaseController.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@protocol PhotoFeedControllerProtocol;
@class PhotoFeedModel;

@interface PhotoFeedBaseController : ASViewController <PhotoFeedControllerProtocol>
@interface PhotoFeedBaseController : ASDKViewController <PhotoFeedControllerProtocol>

@property (nonatomic, strong, readonly) PhotoFeedModel *photoFeed;
@property (nonatomic, strong, readonly) UITableView *tableView;
Expand Down
2 changes: 1 addition & 1 deletion examples/ASDKgram/Sample/PhotoFeedListKitViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
#import <AsyncDisplayKit/AsyncDisplayKit.h>
#import "PhotoFeedControllerProtocol.h"

@interface PhotoFeedListKitViewController<ASCollectionNode> : ASViewController <PhotoFeedControllerProtocol>
@interface PhotoFeedListKitViewController<ASCollectionNode> : ASDKViewController <PhotoFeedControllerProtocol>

@end
4 changes: 2 additions & 2 deletions examples/ASMapNode/Sample/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
//

#import <AsyncDisplayKit/ASViewController.h>
#import <AsyncDisplayKit/ASDKViewController.h>

@interface ViewController : ASViewController
@interface ViewController : ASDKViewController


@end
Expand Down
4 changes: 2 additions & 2 deletions examples/ASViewController/Sample/DetailViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
//

#import <AsyncDisplayKit/ASViewController.h>
#import <AsyncDisplayKit/ASDKViewController.h>
#import "DetailRootNode.h"

@interface DetailViewController : ASViewController<DetailRootNode *>
@interface DetailViewController : ASDKViewController<DetailRootNode *>

@end
4 changes: 2 additions & 2 deletions examples/ASViewController/Sample/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
//

#import <AsyncDisplayKit/ASViewController.h>
#import <AsyncDisplayKit/ASDKViewController.h>
#import <AsyncDisplayKit/ASTableNode.h>

@interface ViewController : ASViewController<ASTableNode *>
@interface ViewController : ASDKViewController<ASTableNode *>


@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@end

@interface OverviewComponentsViewController : ASViewController
@interface OverviewComponentsViewController : ASDKViewController


@end
Expand Down
2 changes: 1 addition & 1 deletion examples/CatDealsCollectionView/Sample/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#import <AsyncDisplayKit/AsyncDisplayKit.h>

@interface ViewController : ASViewController
@interface ViewController : ASDKViewController

@end
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import UIKit
import AsyncDisplayKit

class ViewController: ASViewController<ASCollectionNode>, MosaicCollectionViewLayoutDelegate, ASCollectionDataSource, ASCollectionDelegate {
class ViewController: ASDKViewController<ASCollectionNode>, MosaicCollectionViewLayoutDelegate, ASCollectionDataSource, ASCollectionDelegate {

var _sections = [[UIImage]]()
let _collectionNode: ASCollectionNode
Expand Down
2 changes: 1 addition & 1 deletion examples/CustomCollectionView/Sample/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
#import <UIKit/UIKit.h>
#import <AsyncDisplayKit/AsyncDisplayKit.h>

@interface ViewController : ASViewController
@interface ViewController : ASDKViewController

@end
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#import <AsyncDisplayKit/AsyncDisplayKit.h>

@interface ViewController : ASViewController
@interface ViewController : ASDKViewController

@end
2 changes: 1 addition & 1 deletion examples/Kittens/Sample/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#import <AsyncDisplayKit/AsyncDisplayKit.h>

@interface ViewController : ASViewController
@interface ViewController : ASDKViewController

@end
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import AsyncDisplayKit

class LayoutExampleViewController: ASViewController<ASDisplayNode> {
class LayoutExampleViewController: ASDKViewController<ASDisplayNode> {

let customNode: LayoutExampleNode

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import AsyncDisplayKit

class OverviewViewController: ASViewController<ASTableNode> {
class OverviewViewController: ASDKViewController<ASTableNode> {
let tableNode = ASTableNode()
let layoutExamples: [LayoutExampleNode.Type]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#import <AsyncDisplayKit/AsyncDisplayKit.h>

@interface LayoutExampleViewController : ASViewController
@interface LayoutExampleViewController : ASDKViewController
- (instancetype)initWithLayoutExampleClass:(Class)layoutExampleClass NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithNode:(ASDisplayNode *)node NS_UNAVAILABLE;
@end
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
#import <AsyncDisplayKit/AsyncDisplayKit.h>


@interface OverviewViewController : ASViewController
@interface OverviewViewController : ASDKViewController

@end
2 changes: 1 addition & 1 deletion examples/PagerNode/Sample/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#import <AsyncDisplayKit/AsyncDisplayKit.h>

@interface ViewController : ASViewController<ASPagerNode *>
@interface ViewController : ASDKViewController<ASPagerNode *>

@end
12 changes: 6 additions & 6 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ Featuring:

![ASTableViewStressTest Example App Screenshot](https://github.com/AsyncDisplayKit/Documentation/raw/master/docs/static/images/example-app-screenshots/ASTableViewStressTest.png)

### ASViewController [ObjC]
### ASDKViewController [ObjC]

![ASViewController Example App Screenshot](https://github.com/AsyncDisplayKit/Documentation/raw/master/docs/static/images/example-app-screenshots/ASViewController.png)
![ASDKViewController Example App Screenshot](https://github.com/AsyncDisplayKit/Documentation/raw/master/docs/static/images/example-app-screenshots/ASDKViewController.png)

Featuring:
- ASViewController
- ASDKViewController
- ASTableView
- ASMultiplexImageNode
- ASLayoutSpec
Expand All @@ -56,7 +56,7 @@ Featuring:

Featuring:
- ASDK Swift compatibility
- ASViewController
- ASDKViewController
- ASCollectionView
- thread affinity
- ASLayoutSpec
Expand Down Expand Up @@ -150,7 +150,7 @@ Featuring:
![Swift Example App Screenshot](https://github.com/AsyncDisplayKit/Documentation/raw/master/docs/static/images/example-app-screenshots/Swift.png)

Featuring:
- ASViewController with ASTableNode
- ASDKViewController with ASTableNode

### SynchronousConcurrency [ObjC]

Expand All @@ -169,7 +169,7 @@ The internal features are:

Also provided are two such implementations:
-[ASCellNode setNeverShowPlaceholders:], which integrates with both Tables and Collections
-[ASViewController setNeverShowPlaceholders:], which should work with Nav and Tab controllers.
-[ASDKViewController setNeverShowPlaceholders:], which should work with Nav and Tab controllers.

Lastly, on ASDisplayNode, a new property .shouldBypassEnsureDisplay allows individual node types
to exempt themselves from blocking the main thread on their display.
Expand Down
2 changes: 1 addition & 1 deletion examples/SocialAppLayout-Inverted/Sample/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

#import <AsyncDisplayKit/AsyncDisplayKit.h>

@interface ViewController : ASViewController
@interface ViewController : ASDKViewController
@end
2 changes: 1 addition & 1 deletion examples/SocialAppLayout/Sample/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

#import <AsyncDisplayKit/AsyncDisplayKit.h>

@interface ViewController : ASViewController
@interface ViewController : ASDKViewController
@end
2 changes: 1 addition & 1 deletion examples/Swift/Sample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import UIKit
import AsyncDisplayKit

final class ViewController: ASViewController<ASDisplayNode>, ASTableDataSource, ASTableDelegate {
final class ViewController: ASDKViewController<ASDisplayNode>, ASTableDataSource, ASTableDelegate {

struct State {
var itemCount: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import AsyncDisplayKit

class PhotoFeedTableNodeController: ASViewController<ASTableNode> {
class PhotoFeedTableNodeController: ASDKViewController<ASTableNode> {

// MARK: Lifecycle

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

#import <AsyncDisplayKit/AsyncDisplayKit.h>

@interface CollectionViewController : ASViewController<ASCollectionNode *>
@interface CollectionViewController : ASDKViewController<ASCollectionNode *>
@end
2 changes: 1 addition & 1 deletion examples_extra/ASTraitCollection/Sample/KittenNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@

// The default action when an image node is tapped. This action will create an
// OverrideVC and override its display traits to always be compact.
+ (void)defaultImageTappedAction:(ASViewController *)sourceViewController;
+ (void)defaultImageTappedAction:(ASDKViewController *)sourceViewController;
@end
2 changes: 1 addition & 1 deletion examples_extra/ASTraitCollection/Sample/KittenNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ - (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
return [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(kOuterPadding, kOuterPadding, kOuterPadding, kOuterPadding) child:stackSpec];
}

+ (void)defaultImageTappedAction:(ASViewController *)sourceViewController
+ (void)defaultImageTappedAction:(ASDKViewController *)sourceViewController
{
OverrideViewController *overrideVC = [[OverrideViewController alloc] init];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
* This is a fairly stupid VC that's main purpose is to show how to override ASDisplayTraits.
* Take a look at `defaultImageTappedAction` in KittenNode to see how this is accomplished.
*/
@interface OverrideViewController : ASViewController<OverrideNode *>
@interface OverrideViewController : ASDKViewController<OverrideNode *>
@property (nonatomic, copy) dispatch_block_t closeBlock;
@end
Loading

0 comments on commit d3949e8

Please sign in to comment.