【问题标题】:Passing String with Notification and then pass to class使用通知传递字符串,然后传递给类
【发布时间】:2012-11-15 21:23:26
【问题描述】:

我有一个问题,我为 ipad 应用程序工作,在这个应用程序的主视图中,我有一个自定义 uitableviewcontroller 的实例,在行单击时,我发布了一个传递对象并运行方法的通知

- (void) drawWebView:(id) sender {

    NSDictionary *dict = [[sender userInfo] copy];
    self.objTesto = [dict objectForKey:@"Testo"];
    self.txtWeb = self.objTesto.testo;

    //[self setWebView:self.txtWeb];
    [self.textWebView loadRequest:[self creaFileHTML:text]];
}

当我在我的类的 webview 上设置加载请求时,如果我使用 setWebView 方法创建 uiwebview 的子类:使用简单的 NSLog()

[self setWebView:self.txtWeb];
//[self.textWebView loadRequest:[self creaFileHTML:text]];

我收到此错误:

由于未捕获的异常而终止应用程序 'NSInvalidArgumentException',原因:'-[__NSCFString userInfo]: 无法识别的选择器发送到实例 0xee3a1e0'

【问题讨论】:

  • drawWebView:setWebView:是什么关系? (我还将 drawWebView:(id) sender 更改为 drawWebView:(NSNotification *) notification 以便您在编译时捕获类型错误。)
  • 无相关性,drawWebView在主视图上,当主视图收到来自uitableviewcontroller的通知时运行此方法,setView是uiwebview子类的方法。

标签: iphone subclass userinfo nscfstring


【解决方案1】:

要么错误的东西被作为参数传递,要么你有一个内存管理问题。你需要找出一个字符串是如何被要求提供它的userInfo的。

如果您更改参数声明并在您的方案中打开僵尸,应该清楚发生了什么。

【讨论】:

    【解决方案2】:

    问题是我启动了错误的类(我有两个类似的类)-愚蠢的错误-.-对不起!

    【讨论】:

      猜你喜欢
      • 2015-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-26
      • 1970-01-01
      • 2012-06-13
      • 2020-04-08
      相关资源
      最近更新 更多