在 Swift 中以编程方式设置 uitableview 的委托和数据源

2023-09-12移动开发问题
0

本文介绍了在 Swift 中以编程方式设置 uitableview 的委托和数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我想为 'tableViewinViewController.swift` 文件设置 delegatedatasource.

I would like to set the delegate and datasource for 'tableViewinViewController.swift` file.

我在 viewDidLoad 函数中编写了这段代码,但它不起作用.

I wrote this code in my viewDidLoad function, but it's not working.

代码:

    tableView.delegate?.self
    tableView.dataSource?.self

我正在使用 CoreData,我的实体名为Note".

I'm working with CoreData and my Entity is named "Note".

希望有人能帮我解决这个问题.

Hope someone can help me to solve this problem.

推荐答案

设置委托和数据源的正确方法是:

The correct way to set the delegate and data source is:

tableView.delegate = self
tableView.dataSource = self

这篇关于在 Swift 中以编程方式设置 uitableview 的委托和数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何在使用 cocos2d 的 iphone 应用程序中使用 MYSQL 数据库连接?
How can i use MYSQL database connection in iphone application useing cocos2d?(如何在使用 cocos2d 的 iphone 应用程序中使用 MYSQL 数据库连接?)...
2024-08-12 移动开发问题
5

“‘NSData’没有可见的@interface 声明选择器‘base64EncodedString’"MKS
quot;No visible @interface for #39;NSData#39; declares the selector #39;base64EncodedStringquot; error in MKStoreKit(“‘NSData’没有可见的@interface 声明选择器‘base64EncodedString’MKStoreKit 中的错误)...
2024-08-12 移动开发问题
3

更新为 ARC 错误
updating to ARC errors(更新为 ARC 错误)...
2024-08-12 移动开发问题
11

对 <GKModalRootViewController: 0xb7e450> 的开始/结束
Unbalanced calls to begin/end appearance transitions for lt;GKModalRootViewController: 0xb7e450gt;(对 lt;GKModalRootViewController: 0xb7e450gt; 的开始/结束外观转换的不平衡调用)...
2024-08-11 移动开发问题
5

如何使 iphone 和 iphone4-retina 兼容的应用程序(在 cocos2d 中完成)轻松适应 ipad?
How to make an iphone and iphone4-retina compatible app (done in cocos2d) easily adapted to ipad?(如何使 iphone 和 iphone4-retina 兼容的应用程序(在 cocos2d 中完成)轻松适应 ipad?)...
2024-08-11 移动开发问题
5

更新 Cocos2d 中的标签值
Update Label Value in Cocos2d(更新 Cocos2d 中的标签值)...
2024-08-11 移动开发问题
9