开发者

UIView addSubview: method error problem

开发者 https://www.devze.com 2022-12-21 06:19 出处:网络
I have the code to add a view [self.view addSubview:RootViewController.view] and it gives me the error error: accessing unknown \'view\' class method

I have the code to add a view [self.view addSubview:RootViewController.view] and it gives me the error error: accessing unknown 'view' class method

here is a bunch more stuff that might be helpful.

CompileC build/iTracker.build/Debug-iphoneos/iTracker.build/Objects-normal/armv6/NewLogViewController.o Classes/NewLogViewController.m normal armv6 objective-c com.apple.compilers.gcc.4_2
cd /Users/markszymanski/Desktop/Programming/iTracker
setenv LANG en_US.US-ASCII
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -x objective-c -arch armv6 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-variable -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk -fvisibility=hidden -gdwarf-2 -mthumb -miphoneos-version-min=3.1.3 -iquote /Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/iTracker-generated-files.hmap -I/Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/iTracker-own-target-headers.hmap -I/Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/iTracker-all-target-headers.hmap -iquote /Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/iTracker-project-headers.hmap -F/Users/markszymanski/Desktop/Programming/iTracker/build/Debug-iphoneos -I/Users/markszymanski/Desktop/Programming/iTracker/build/Debug-iphoneos/include -I/Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/DerivedSources/armv6 -I/Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/DerivedSources -include /var/folders/lv/lv+C4SRgFKyKVw+w5z1F-++++TM/-Caches-/com.apple.Xcode.502/SharedPrecompiledHeaders/iTracker_Prefix-faiusrzfiirznderkbprgchdlcni/iTracker_Prefix.pch -c /Users/markszymanski/Desktop/Programming/iTracker/Classes/NewLogViewController.m -o /Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/Objects-normal/armv6/NewLogViewController.o

/Users/markszymanski/Desktop/Programming/iTracker/Classes/NewLogViewController.m: In function '-[NewLogViewController addLog]':
/Users/markszymanski/Desktop/Programming/iTracker/Classes/NewLogViewController.m:22: warning: passing argument 1 of 'addSubview:' makes pointer from integer without a cast
/Users/markszymanski/Desktop/Programming/iTracker/Classes/NewLogViewController.m:22: error: accessing unknown 'view' class method
{standard input}:515:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_11" minus "L50"
{standard input}:515:symbol: "L_OBJC_SELECTOR_REFERENCES_11" can't be undefined in a subtraction expression
{standard input}:514:non-relocatable subtraction expression, "L_OBJC_CLASSLIST_SUP_REFS_$_0" minus "L49"
{standard input}:514:symbol: "L_OBJC_CLASSLIST_SUP_REFS_$_0" can't be undefined in a subtraction expression
{standard input}:469:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_9" minus "L44"
{standard input}:469:symbol: "L_OBJC_SELECTOR_REFERENCES_9" can't be undefined in a subtraction expression
{standard input}:468:non-relocatable subtraction expression, "L_OBJC_CLASSLIST_REFERENCES_$_2" minus "L43"
{standard input}:468:symbol: "L_OBJC_CLASSLIST_REFERENCES_$_2" can't be undefined in a subtraction expression
{standard input}:467:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_10" minus "L42"
{standard input}:467:symbol: "L_OBJC_SELECTOR_REFERENCES_10" can't be undefined in a subtraction expression
{standard input}:351:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_8" minus "L31"
{standard input}:351:symbol: "L_OBJC_SELECTOR_REFERENCES_8" can't be undefined in a subtraction expression
{standard input}:349:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_7" minus "L29"
{standard input}:349:symbol: "L_OBJC_SELECTOR_REFERENCES_7" can't be undefined in a subtraction expression
{standard input}:348:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_6" minus "L28"
{standard input}:348:symbol: "L_OBJC_SELECTOR_REFERENCES_6" can't be undefined in a subtraction expression
{standard input}:347:non-relocatable subtraction expression, "L_OBJC_CLASSLIST_REFERENCES_$_1" minus "L27"
{standard input}:347:symbol: "L_OBJC_CLASSLIST_REFERENCES_$_1" can't be undefined in a subtraction expression
{standard input}:345:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_5" minus "L23"
{standard input}:345:symbol: "L_OBJC_SELECTOR_REFERENCES_5" can't be undefined in a subtraction expression
{standard input}:159:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_4" minus "L12"
{standard input}:159:symbol: "L_OBJC_SELECTOR_REFERENCES_4" can't be undefined in a subtraction expression
{standard input}:158:non-relocatable subtraction expression, "L_OBJC_CLASSLIST_SUP_REFS_$_0" minus "L11"
{standard input}:158:symbol: "L_OBJC_CLASSLIST_SUP_REFS_$_0" can't be undefined in a subtraction expression
{standard input}:113:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_1" minus "L6"
{standard input}:113:symbol: "L_OBJC_SELECTOR_REFERENCES_1" can't be undefined in a subtraction expression
{standard input}:112:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_3" minus "L5"
{standard input}:112:symbol: "L_OBJC_SELECTOR_REFERENCES_3" can't be undefined in a subtraction expression
{standard input}:111:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_2" minus "L4"
{standard input}:111:symbol: "L_OBJC_SELECTOR_REFERENCES_2" can't be undefined in a subtraction expression
{standard input}:110:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_0" minus "L3"
{standard input}:110:symbol: "L_OBJC_SELECTOR_REFERENCES_0" can't be undefined in a subtraction expression
{standard input}:109:non-relocatable subtraction expression, "L_OBJC_CLASSLIST_SUP_REFS_$_0" minus "L2"
{standard input}:109:symbol: "L_OBJC_CLASSLIST_SUP_REFS_$_0" can't be undefined in a subtraction expression
{standard input}:unknown:Undefined local symbol L_objc_msgSendSuper2$stub
{standard input}:unknown:Undefined local symbol L_objc_msgSend$stub
{standard input}:unknown:Undefined local symbol L_OBJ开发者_运维技巧C_CLASSLIST_SUP_REFS_$_0
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_0
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_2
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_3
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_1
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_4
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_5
{standard input}:unknown:Undefined local symbol L_OBJC_CLASSLIST_REFERENCES_$_1
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_6
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_7
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_8
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_10
{standard input}:unknown:Undefined local symbol L_OBJC_CLASSLIST_REFERENCES_$_2
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_9
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_11

thanks in advance!


RootViewController is the name of the class, not of the instance. Change it to the name of the variable the object of class RootViewController is assigned to.


Objective C can have methods in an object, or in the class type for an object. The "view" method (or attribute in this case) is a method on the object instead of the class. There is no view method on the class. JoostK has it right that you need to use the object name (the variable), instead of the class name.

In the documentation and code the methods that start with "-" are object methods. The ones that start with "+" are class methods.

Class methods are typically factory methods. Most of the time you'll want to use methods on your object, that is, use the variable.


I am encountered this error. My case is because of spelling mistake. please try the following:

instead of: [self.view addSubview:RootViewController.view]

Replace: Note: Small capital of "r" [self.view addSubview:*r*ootViewController.view

If not work, please close check your .h file to copy & paste your class's declaration.

Hope it help :)

Please support my new application - spider smack : http://itunes.apple.com/us/app/spider-smack/id418269071?mt=8 Blockquote

0

精彩评论

暂无评论...
验证码 换一张
取 消