123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //
- // MKRViewController.m
- // MKRRadioManager
- //
- // Created by yyqxiaoyin on 04/15/2019.
- // Copyright (c) 2019 yyqxiaoyin. All rights reserved.
- //
- #import "MKRViewController.h"
- #import "MKRPlayControlViewController.h"
- #import <MKRRadioManager/MKRAVPlayer.h>
- #import <YYCategory/NSString+Utilities.h>
- #import <NSHashTable+MKRRadioManagerAdd.h>
- #import "MKRTestObject.h"
- @interface MKRViewController ()
- @property (nonatomic, strong)UITableView *tableView;
- @property (nonatomic, strong)NSMutableArray *dataSource;
- @property (nonatomic, strong) MKRAVPlayer *player;
- @property (nonatomic, strong) NSHashTable *hashTable;
- @property (nonatomic, strong) NSMutableArray *array;
- @end
- @implementation MKRViewController
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
- dispatch_async(dispatch_get_global_queue(0, 0), ^{
- [self.hashTable makeObjectsPerformSelectorWithObjectsOnMainThread:@selector(testMethod:),@"hello"];
- });
- }
- - (IBAction)refresh:(UIBarButtonItem *)sender {
- [self.dataSource removeAllObjects];
- [self searchDevice];
- }
- - (void)searchDevice{
- [_MKRWIFIDeviceManager searchDeviceWithSearchTime:20 timeBlock:^(NSInteger time) {
- [self.tableView reloadData];
- }];
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
-
- for (NSInteger i = 0; i<10; i++) {
- MKRTestObject *obj = [[MKRTestObject alloc] init];
- [self.array addObject:obj];
- [self.hashTable addObject:obj];
- }
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return self.dataSource.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
- MKRUPnPDevice *device = self.dataSource[indexPath.row];
- cell.textLabel.text = device.deviceName;
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- MKRPlayControlViewController *vc = [[MKRPlayControlViewController alloc] initWithDevice:self.dataSource[indexPath.row]];
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)testMethod{
- MKRLog(@"测试方法");
-
- }
- - (NSMutableArray *)dataSource {
- if (!_dataSource) {
- _dataSource = [NSMutableArray array];
- }
- return _dataSource;
- }
- - (NSHashTable *)hashTable{
- if (!_hashTable) {
- _hashTable = [NSHashTable weakObjectsHashTable];
- }
- return _hashTable;
- }
- - (NSMutableArray *)array{
- if (!_array) {
- _array = [NSMutableArray array];
- }
- return _array;
- }
- @end
|