xcode - AppDelegate 错误

标签 xcode swift

我想我发布了一些关于这个的东西,好吧,这个问题几乎没有再发生了 直到现在,当我尝试创建一个 TableView 时!

代码如下:

import UIKit

class ViewController: UITableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell

        {
            var cell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath:indexPath) as UITableViewCell
            cell.textLabel.text = "Cell number \(indexPath.row)"
            return cell
        }
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
    {
        return 11 
    }


}

顺便说一句 -> 我正在使用 Swift 编程语言使用 Xcode 6.1!

编辑 -> 错误是“线程 1:SIGABRT 信号”

谢谢, 应用程序wiftgb

错误日志

2014-11-12 20:42:40.672 tableViewTutorial[5949:94056] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "vXZ-lx-hvc-view-kh9-bI-dsS" nib but didn't get a UITableView.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000107377f35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000108ebbbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x0000000107377e6d +[NSException raise:format:] + 205
    3   UIKit                               0x0000000107ee5415 -[UITableViewController loadView] + 249
    4   UIKit                               0x0000000107d287f9 -[UIViewController loadViewIfRequired] + 75
    5   UIKit                               0x0000000107d5706b -[UINavigationController _layoutViewController:] + 44
    6   UIKit                               0x0000000107d575b5 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 216
    7   UIKit                               0x0000000107d576b4 -[UINavigationController _startTransition:fromViewController:toViewController:] + 92
    8   UIKit                               0x0000000107d58487 -[UINavigationController _startDeferredTransitionIfNeeded:] + 523
    9   UIKit                               0x0000000107d58f47 -[UINavigationController __viewWillLayoutSubviews] + 43
    10  UIKit                               0x0000000107e9e509 -[UILayoutContainerView layoutSubviews] + 202
    11  UIKit                               0x0000000107c7c973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
    12  QuartzCore                          0x000000010bb7ade8 -[CALayer layoutSublayers] + 150
    13  QuartzCore                          0x000000010bb6fa0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    14  QuartzCore                          0x000000010bb6f87e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    15  QuartzCore                          0x000000010badd63e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
    16  QuartzCore                          0x000000010bade74a _ZN2CA11Transaction6commitEv + 390
    17  UIKit                               0x0000000107c0154d -[UIApplication _reportMainSceneUpdateFinished:] + 44
    18  UIKit                               0x0000000107c02238 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2642
    19  UIKit                               0x0000000107c00bf2 -[UIApplication workspaceDidEndTransaction:] + 179
    20  FrontBoardServices                  0x000000010aa482a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
    21  CoreFoundation                      0x00000001072ad53c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    22  CoreFoundation                      0x00000001072a3285 __CFRunLoopDoBlocks + 341
    23  CoreFoundation                      0x00000001072a3045 __CFRunLoopRun + 2389
    24  CoreFoundation                      0x00000001072a2486 CFRunLoopRunSpecific + 470
    25  UIKit                               0x0000000107c00669 -[UIApplication _run] + 413
    26  UIKit                               0x0000000107c03420 UIApplicationMain + 1282
    27  tableViewTutorial                   0x0000000107198f4e top_level_code + 78
    28  tableViewTutorial                   0x0000000107198f8a main + 42
    29  libdyld.dylib                       0x0000000109695145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

最佳答案

尝试为您的 TableView 委托(delegate)实现 numberOfSections,它可能会崩溃,因为缺少它。

关于xcode - AppDelegate 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26896299/

相关文章:

xcode - Swift 通用类类型既是子类又符合协议(protocol)

ios - 字符串数组swift 3中不区分大小写的匹配搜索

objective-c - 无法从 SQLite 数据库检索值

swift - 在 Swift 4 中,将 String 值类型转换为 Float 值的正确方法是什么?

ios - Swift - 节点被触摸后延迟,直到它可以再次被触摸

swift - 无法向菜单项添加操作

ios - SwiftUI 转义闭包捕获变异的 'self' 参数

ios - Xcode 7 : Linker warning for -F/<path> but no settings in app. xcodeproj/project.pbxproj 匹配<路径>

ios - 使用 UICollectionView 继续

Ios 用户通知内容附件(图片)调整大小/隐藏通知扩展(长按)