菜鸟教程小白 发表于 2022-12-12 23:40:42

ios - TableView NSInternalInconsistencyException


                                            <p><p>更新:似乎我设法识别了单元格,因此解决了原始问题。但是现在,剪断相同的代码,我收到以下错误:</p>

<pre><code>2012-10-31 15:21:41.857 Laktase -: unrecognized selector sent to instance 0x74a5a30
2012-10-31 15:21:41.858 Laktase *** Terminating app due to uncaught exception &#39;NSInvalidArgumentException&#39;, reason: &#39;-: unrecognized selector sent to instance 0x74a5a30&#39;
*** First throw call stack:
(0x1f9f012 0x13dce7e 0x202a4bd 0x1f8ebbc 0x1f8e94e 0x1714af 0x171674 0x4430 0xd2f4b 0xd301f 0xbb80b 0xcc19b 0x6892d 0x13f06b0 0x259bfc0 0x259033c 0x259beaf 0x1078cd 0x501a6 0x4ecbf 0x4ebd9 0x4de34 0x4dc6e 0x4ea29 0x51922 0xfbfec 0x48bc4 0x48dbf 0x48f55 0x51f67 0x15fcc 0x16fab 0x28315 0x2924b 0x1acf8 0x1efadf9 0x1efaad0 0x1f14bf5 0x1f14962 0x1f45bb6 0x1f44f44 0x1f44e1b 0x167da 0x1865c 0x268d 0x25b5 0x1)
libc++abi.dylib: terminate called throwing an exception
(lldb)
</code></pre>

<p>//更新结束</p>

<p>我正在尝试查询数据库,然后第一次在表中列出结果。 </p>

<p>当我将 numberOfRowsInSection 从 0 更改为 时,应用程序崩溃并出现 NSInternalInconsistencyException 错误。 matchData 是一个包含核心数据结果的数组。我就是想不通为什么 不起作用。</p>

<p>这是我的代码:</p>

<pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSEntityDescription *entity = ;
    NSFetchRequest *request = ;
    ;
    NSPredicate *predicate = ; // @&#34;ANY Tablette.dosis like &#39;1&#39;&#34;];
    ;
    NSError *error;
    NSArray *matchingData = ;
    return ;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @&#34;Cell&#34;;
UITableViewCell *cell = ;

// Configure the cell...


NSEntityDescription *entity = ;
NSFetchRequest *request = ;
;
NSPredicate *predicate = ;
;
NSError *error;
NSArray *matchingData = ;

cell.textLabel.text = ;

return cell;
}
</code></pre>

<p>这是一个异常(exception):</p>

<pre><code>2012-10-31 12:10:38.995 Laktase *** Assertion failure in -, /SourceCache/UIKit_Sim/UIKit-2372/UITableView.m:4460
2012-10-31 12:10:38.996 Laktase *** Terminating app due to uncaught exception &#39;NSInternalInconsistencyException&#39;, reason: &#39;unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard&#39;
*** First throw call stack:
(0x1f9f012 0x13dce7e 0x1f9ee78 0xb66f35 0xc9d14 0x4078 0xd2f4b 0xd301f 0xbb80b 0xcc19b 0x6892d 0x13f06b0 0x259bfc0 0x259033c 0x259beaf 0x1078cd 0x501a6 0x4ecbf 0x4ebd9 0x4de34 0x4dc6e 0x4ea29 0x51922 0xfbfec 0x48bc4 0x48dbf 0x48f55 0x51f67 0x15fcc 0x16fab 0x28315 0x2924b 0x1acf8 0x1efadf9 0x1efaad0 0x1f14bf5 0x1f14962 0x1f45bb6 0x1f44f44 0x1f44e1b 0x167da 0x1865c 0x249d 0x23c5 0x1)
libc++abi.dylib: terminate called throwing an exception
(lldb)
</code></pre>

<p>非常感谢。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您必须为 Nib/Storyboard 中的原型(prototype)单元分配正确的单元标识符。</p>

<p>错误很明显:'无法使具有标识符 Cell 的单元出队 - 必须注册一个 nib 或一个类</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - TableView NSInternalInconsistencyException,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/13156668/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/13156668/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - TableView NSInternalInconsistencyException