问题-MethodAddress返回NIL?MethodAddress与published的关系?
问题现象:有位朋友(397085381)在Q群里问“为什么书上的可以访问,而自己写的代码访问时为nil”
问题原因:因为要用“Self.MethodAddress('Test')”访问,方法必须放在“published”下。
问题处理:增加“published”就好了。
解答人员:541011510、316405484、397085381。
实例代码:
unit Unit2; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls; type
TTest = procedure of object;
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
published//使用MethodAddress必须定义在发布区的方法
procedure Test;
{ Public declarations }
end; var
Form2: TForm2; implementation {$R *.dfm} procedure TForm2.Button1Click(Sender: TObject);
var
oP: TMethod;
otest: Ttest;
begin
oP.Data := Pointer(Self);
op.Code := Self.MethodAddress('Test');//使用MethodAddress必须定义在published(发布区)的方法
// op.Code := @TForm2.test; //什么方法都可以返回地址
if Assigned(op.Code) then
begin
otest := Ttest(op);
otest;
end;
end; procedure TForm2.Test;
begin
ShowMessage('Test');
end; end.
问题-MethodAddress返回NIL?MethodAddress与published的关系?的更多相关文章
- 解决NSData转NSString返回nil的问题
// 字符串转Data NSString *str =@"jesfds"; NSData *data =[str dataUsingEncoding:NSUTF8StringEnc ...
- 解决 pathForResource 返回 nil的问题
点击(此处)折叠或打开 NSString* path = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@&quo ...
- Swift - 初始化方法返回nil表示初始化失败
自Swift1.1开始,初始化init方法便有返回nil的能力.我们可以在init声明的时候在其后面加上一个 ? 或者 ! 来表示初始化失败时可能返回nil. 比如,给Int类添加一个将字符串初始化成 ...
- 为什么有时候NSData转换成NSString的时候返回nil
为什么有时候NSData转换成NSString的时候返回nil 有时候,NSData明明有值,可是,当转换成NSString的时候,却没有值,现在来进行测试:) -现在提供测试用素材- 源码如下: / ...
- redis lpop key 当key不存在时,返回nil , 监测redis执行语句是否正常执行
Lpop key 返回值: 列表的头元素. 当key 不存在时, 返回 nil . 需求: 开发在执行 lpop key 时, 出现问题 , 执行语句卡住, 不能执行下去 , 需对此做一个监测 由于 ...
- redis的lua脚本拓展,返回nil及其判断
redis自带的lua脚本 127.0.0.1:6379> hget team wyc "{\"name\":\"wyycc\",\" ...
- 【原创】大叔问题定位分享(36)openresty(nginx+lua)中获取不到post数据,ngx.req.get_body_data返回nil
openresty(nginx+lua)中获取不到post数据,ngx.req.get_body_data返回nil This function returns nil if the request ...
- 解决pathForResource返回nil, 无法读取plist文件问题
有很多人在设置plist文件的时候, 会发现读取不了plist文件里面的内容, 返回值为nil, 下面我们来解决一下这个问题. 首先我们打开工程并且按照下面的步骤来设置: 设置好后, 我们来写一段代码 ...
- Swift - IBOutlet返回nil(fatal error: unexpectedly found nil while unwrapping an Optional value)
在Swift 中 ViewController 默认构造方法不关联同名的xib文件 在使用OC的时候,调用ViewController的默认构造函数,会自动关联到一个与ViewController名字 ...
随机推荐
- POJ 2391 Ombrophobic Bovines (Floyd + Dinic +二分)
Ombrophobic Bovines Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11651 Accepted: 2 ...
- Runway for Mac(UML 流程图绘图工具)破解版安装
1.软件简介 Runway 是 macOS 系统上一款强大实用的软件开发工具,Runway for Mac 是一个界面简单功能强大的UML设计师.此外,Runway for Mac 带给你所有你 ...
- 【struts2】action中使用通配符
在以前的学习中,<action>元素的配置,都是用明确的配置,其name.class等属性都是一个明确的值.其实Struts2还支持class属性和method属性使用来自name属性的通 ...
- SQL Performance Analyzer
SQL Performance Analyzer 系统发生变更,比如升级数据库.增加索引,都会可能导致sql的执行计划发生改变,从而影响sql的性能. 如果能预知系统变更会对sql的性能的影响,就可以 ...
- windows Server 2012安装GUI
1.进入PowerShell 在命令行提示输入符处,直接输入: PowerShell 2.安装GUI 在命令行提示输入符处,直接输入: Install-WindowsFeature Server-Gu ...
- dart --- 更符合程序员编程习惯的javascript替代者
dart是google在2011年推出的一门语言,提供较为丰富的lib,并支持将代码转变为javascript,其demo code 和 demo app 也是以web前端代码来展示的. 其语言特性较 ...
- IRGAN:A Minimax Game for Unifying Generative and Discriminative Information Retrieval Models
https://arxiv.org/pdf/1705.10513.pdf 论文阅读笔记: https://www.cnblogs.com/liaohuiqiang/p/9694277.html htt ...
- centos 6.3 64位下cpuminer +mining_proxy 挖掘莱特币(LTC)教程
1.下载软件: cpuminer: http://sourceforge.net/projects/cpuminer/files/ 找到对应的版本,我的服务器是centos64的,找了个当前最高版本: ...
- 微信小程序 自定义单选复选按钮组的实现(用于实现购物车产品列表功能)
(一)单选按钮组 模型图如下: index.js Page({ data: { parameter: [{ id: 1, name: '银色' }, { id: 2, name: '白色' },{ i ...
- 在 Windows Server 2008 中部署带 SignalR 的网站出错
一直是在 Windows Server 2008 R2 或更高版本的 Windows 中进行部署,没有遇到过此现象,不知道是不是因为系统的原因. 现象为从浏览器访问配置 signalr 的地址返回 4 ...