【问题标题】:Invalid receiver type for NSIntegerNSInteger 的接收器类型无效
【发布时间】:2011-03-01 14:22:52
【问题描述】:
  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSLog(@"bla %@", [节数]);

    return [拥有数]; }

有谁知道如何实现一个简单的 NSLog,因为我遇到了一个错误。

【问题讨论】:

    标签: objective-c iphone ipad


    【解决方案1】:

    section 的类型是 NSInteger。 NSInteger 类型声明的变量没有名称计数的函数。您可以使用以下代码打印部分值。

    NSLog(@"bla %d",section)

    【讨论】:

      【解决方案2】:

      这是最常用的格式说明符:

      • %d 或 %D 表示整数 (int)
      • %f 表示浮点数
      • %@ 用于字符串(一般)

      您可以在此处查看其他格式说明符:
      https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html

      【讨论】:

        【解决方案3】:

        NSLog(@"bla %d", section)

        NSInteger 基本上只是一个 int(但具有稍微广为人知的特征)。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2021-04-03
          • 2017-11-08
          • 1970-01-01
          • 2011-06-22
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多