use of undeclared identifier *** , did you mean ***. in xcode

A property is not the same thing os a instance variable, you should read a little bit of them, there‘s plenty of sources in the internet.

Summarizing, a property is the combination of the instance variable (by default, automaticated declaraded with a underscore), and it‘s get and set methods.

To access the property inside your class, you should call for self.propertyName, in your case it would be self.myTextfield. This will access the gererated get method of the property. You can always, of course if you are inside the class, skip the get method and access the variable directly. In this case, it would be _myTextfield.

If you are not confortable with this automaticated instance variable generated, you can always declare your own and bind it with the property with the @synthesize command. Like this:

@synthesize myTextfieldProperty = myTextfieldVariable;

Here‘s more information about the synthesize. As I said before, this command binds one iVar to a property. So, when you execute the line above, inside your class, you can either reference to the iVar directly, calling myTextfieldVariable, or by the property, self.myTextfieldProperty (there are a few differences actually between them, but I‘m not entering in details).

If you don‘t write the synthesize, what xcode does for you, automatically, is this:

@synthesize myTextfield = _myTextfield;

So, in your case, as you does not synthesize your property, xcode automatically created the iVar with the underscore in the beginning. It‘s just a pattern that xcode follows.

The line @synthesize myTextfield;, without binding an iVar directly, is simple the same as

@synthesize myTextfield = myTextfield;

i.e. you are creating an iVar with the same name of your property. And why these two lines are actyally the same thing? I don‘t know, again, it‘s just a pattern that xcode follows.

时间: 2024-10-12 19:43:12

use of undeclared identifier *** , did you mean ***. in xcode的相关文章

error C2065: 'TIME_UTC' : undeclared identifier

boost_1_55_0\boost\threadpool\task_adaptors.hpp(138) : error C2065: 'TIME_UTC' : undeclared identifier boost_1_55_0   version threadpool-0_2_5   version 解决办法:(This patch fixes compilation) --- dependencies/threadpool/include/threadpool/task_adaptors.

error C2065: 'assert' : undeclared identifier

F:\VC6.0 : error C2065: 'assert' : undeclared identifier 导入#include <assert.h> error C2065: 'assert' : undeclared identifier

error C2065: &#39;CArchiveStream&#39; : undeclared identifier

release:模式下 问题: 在导入JPEG文件时要使用到  CArchiveStream类  但是编译的时候会出现  'CArchiveStream'   :   undeclared   identifier    编译错误.即使追加了 #include <afxpriv.h> #include <afxpriv2.h> 有时候还是不能解决问题. 解决方法: 在预编译文件stdafx.h文件中追加  #ifndef _AFX_NO_OLE_SUPPORT #include &

【原】iOS 同时重写setter和getter时候报错:Use of undeclared identifier &#39;_name&#39;;did you mean &#39;name&#39;

写了那么多的代码了,平时也没有怎么注意会报这个错误,因为平时都很少同时重写setter和getter方法,一般的话,我们大概都是使用懒加载方法,然后重写getter方法,做一个非空判断.然后有时候根据需求,要同时重写属性的setter和getter方法.系统就会报错误::Use of undeclared identifier '_name';did you mean 'name' MARK:如果不想了解太多,直接的解决方法: 在@implementation 实现中添加一行代码就OK了 @sy

&#39;IActiveDesktop&#39; : undeclared identifier 的处理

在一个COM例子中,编译出现了错误,这个例子很简单,用vc新建一个Win32 Console Application项目,然后选择An application that supports MFC,然后加入如下函数,并在_tmain()里调用. TestIActiveDesktop() { WCHAR wszWallpaper [MAX_PATH]; CString strPath; HRESULT hr; IActiveDesktop* pIAD; // 1. 初始化COM库(让Windows加

VS2008编译错误:error C2065: &#39;PMIB_TCPSTATS&#39; : undeclared identifier c:\program files (x86)\microsoft sdks\windows\v7.0a\include\iphlpapi.h 411

安装了VS2008编译之前的程序,结果出现了编译错误,以为是VS2008的Sp1补丁没装好,重装补丁后还是不行,编译错误如下: 双击错误会定位在iphlpapi.h中, 一个可行的解决办法是:把iphlpapi.h文件的line386---line421 都注释掉了: 然后再尝试编译,编译成功,运行也没有问题. 看起来,这几行代码不会影响程序运行. VS2008编译错误:error C2065: 'PMIB_TCPSTATS' : undeclared identifier c:\program

【MFC】error C2065: &#39;AfxGetFileName&#39; : undeclared identifier

一开始在debug目录下无任何错误 在release下总是 --------------------Configuration: maizang - Win32 Debug--------------------Compiling...APPINIT.CPPC:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\APPINIT.CPP(90) : error C2065: 'AfxGetFileName' : undeclared identi

Undeclared identifier:XXX

未识别错误,是因拼写错误或找不到定义文件. 下面列举一些类型和函数用到的单元. _Stream ADODB_TLB akTop, akLeft, akRight, akBottom Controls Application (the variable not a type) Forms Beep SysUtils or Windows (different functions) CGID_EXPLORER ShlObj CN_BASE Controls CoInitialize ActiveX

apache源码编译时报错ssl_engine_init.c:546: error: &#39;STACK&#39; undeclared (first use in this function)

操作系统:centos6.4 X86_64 apache版本:httpd-2.2.6 openssl版本:openssl-1.0.1e 源码编译apache时报如下错误: ssl_engine_init.c: In function 'ssl_init_ctx_protocol': ssl_engine_init.c:390: warning: assignment discards qualifiers from pointer target type ssl_engine_init.c:39