소스 검색

版本升级维护

尹永奇 5 년 전
부모
커밋
eb013316fb

+ 0 - 15
Example/MKRRadioManager/MKRViewController.m

@@ -37,21 +37,6 @@
 - (void)viewDidLoad
 {
     [super viewDidLoad];
-//    http://openod.sign.qingting.fm/mp3/3235228_128.mp3?sign=47d740e207069a86c539d2c78528f9c2&t=5d8d2d55&clientID=OTRmNmQyZDgtNWZiMi0xMWU3LTkyM2YtMDAxNjNlMDAyMGFk
-//    NSString *urlString = [@"http://radio1964-zhibo.oss-cn-shenzhen.aliyuncs.com/audio_data/180112/榜单bandcamp第一期20181月12.mp3" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
-    NSString *string1 = [@"http://openod.sign.qingting.fm/mp3/3235228_128.mp3?sign=47d740e207069a86c539d2c78528f9c2&t=5d8d2d55&clientID=OTRmNmQyZDgtNWZiMi0xMWU3LTkyM2YtMDAxNjNlMDAyMGFk" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
-//    NSString *realString = [[urlString urlEncodeString] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
-    NSURL *url = [NSURL URLWithString:string1];
-//    self.player = [[MKRAVPlayer alloc]initWithContentURL:url];
-//    self.player.shouldAutoPlay = YES;
-//    [self.player play];
-//    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
-//    self.tableView.delegate = self;
-//    self.tableView.dataSource = self;
-//    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
-//    [self.view addSubview:self.tableView];
-//    [[MKRWIFIDeviceManager shareManager] startUpnp];
-//    [self searchDevice];
 }
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

+ 2 - 0
MKRRadioManager/Classes/MKRRadioManager/Category/NSHashTable+MKRRadioManagerAdd.h

@@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 - (void)makeObjectsPerformSelectorWithObjects:(SEL)sel, ...;
 
+- (void)makeObjectsPerformSelectorWithObjectsOnMainThread:(SEL)sel, ...;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 29 - 0
MKRRadioManager/Classes/MKRRadioManager/Category/NSHashTable+MKRRadioManagerAdd.m

@@ -35,6 +35,35 @@
     }
 }
 
+- (void)makeObjectsPerformSelectorWithObjectsOnMainThread:(SEL)sel, ...{
+    va_list args;
+    va_start(args, sel);
+    NSArray *allObject = self.allObjects;
+    for (NSInteger i = 0; i<allObject.count; i++) {
+        if (allObject.count > i) {
+            id obj = allObject[i];
+            if ([obj respondsToSelector:sel]) {
+                NSMethodSignature *sig = [obj methodSignatureForSelector:sel];
+                if (!sig) {
+                    [obj doesNotRecognizeSelector:sel];
+                }
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:sig];
+                    if (!invocation) {
+                        [obj doesNotRecognizeSelector:sel];
+                    }
+                    [invocation setTarget:obj];
+                    [invocation setSelector:sel];
+                    [self setInv:invocation withSig:sig andArgs:args];
+                    [invocation invoke];
+                });
+                
+            }
+        }
+    }
+}
+
+
 - (void)setInv:(NSInvocation *)inv withSig:(NSMethodSignature *)sig andArgs:(va_list)args {
     NSUInteger count = [sig numberOfArguments];
     for (int index = 2; index < count; index++) {