代码下方
@interface BaseViewController ()
@property (nonatomic, strong) UISearchController *searchController;
@property (nonatomic, strong) UIBarButtonItem *searchBarButtonItem;
@property (nonatomic, strong) UIBarButtonItem *accountBarButtonItem;
@property (nonatomic, strong) UITableViewController *searchResultsController;
@end
@implementation BaseViewController
- (instancetype)init {
if (self = [super init]) {
UIImage *accountIcon = [UIImage imageNamed:@"account-male-icon@2x.png"];
UIBarButtonItem *accountBarButtonItem = [[UIBarButtonItem alloc] initWithImage:accountIcon style:UIBarButtonItemStylePlain target:self action:@selector(accountButtonPressed:)];
UIBarButtonItem *searchBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(searchButtonPressed:)];
[self setSearchResultsController:[[UITableViewController alloc] init]];
[self setSearchController:[[UISearchController alloc] initWithSearchResultsController:[self searchResultsController]]];
[[[self searchResultsController] tableView] setDataSource:self];
[[[self searchResultsController] tableView] setDelegate:self];
[[[self searchResultsController] tableView] setTableHeaderView:[[self searchController] searchBar]];
[[self searchController] setSearchResultsUpdater:self];
[[self searchController] setDelegate:self];
[[self searchController] setHidesNavigationBarDuringPresentation:YES];
[[self searchController] setDimsBackgroundDuringPresentation:YES];
[[[self searchController] searchBar] setDelegate:self];
[self setDefinesPresentationContext:YES];
[self setSearchBarButtonItem:searchBarButtonItem];
[self setAccountBarButtonItem:accountBarButtonItem];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
[[self navigationItem] setLeftBarButtonItem:[self accountBarButtonItem]];
[[self navigationItem] setRightBarButtonItem:[self searchBarButtonItem]];
}
- (IBAction)searchButtonPressed:(id)sender {
[self presentViewController:[self searchController] animated:YES completion:nil];
}
在function myFunc(theObject) {
theObject.brand = "Toyota";
}
对象中添加属性名为myFunc
的成员。
window
对于以下代码,
> window['myFunc']
function myFunc()
class Polygon {
constructor(height, width) {
this.height = height;
this.width = width;
}
}
如何存储在Polygon
对象中?