【问题标题】:Objective-C Passing Messages with Arguments in performSelectorOnMainThread: [closed]Objective-C 在 performSelectorOnMainThread 中使用参数传递消息:[关闭]
【发布时间】:2012-08-14 17:34:55
【问题描述】:

当传递给@selector 的方法有参数时需要语法帮助。谢谢!

//This works
dispatch_async(kBgQueue, ^{ 

 [self performSelectorOnMainThread:@selector(hydrateList) withObject:nil waitUntilDone:YES];   

});



//But what about when the method in the selector has arguments?
//This is incorrect, syntactically
  dispatch_async(kBgQueue, ^{ 

     [self performSelectorOnMainThread:@selector(hydrateListForCategory:self.categorySelected) withObject:nil waitUntilDone:YES];
  });

【问题讨论】:

标签: objective-c ios5 objective-c-blocks performselector


【解决方案1】:

提示:这就是“withObject:”部分存在的原因。

提示 2:Apple 为其框架提供了非常好的文档。

提示 3:

[self performSelectorOnMainThread:@selector(hydrateListForCategory:) withObject:self.categorySelected waitUntilDone:YES];

【讨论】:

    【解决方案2】:
    [self performSelectorOnMainThread:@selector(hydrateListForCategory:) withObject:self.categorySelected waitUntilDone:YES];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-30
      • 1970-01-01
      相关资源
      最近更新 更多