当前位置: 代码迷 >> Iphone >> 超级新手helloworld
  详细解决方案

超级新手helloworld

热度:54   发布时间:2016-04-25 06:01:04.0
超级新手求助helloworld
小弟今天刚刚开始接触,照着官网说的整了一个helloworld,结果就是不行。跪求指点~~~~Orz

以下是错误代码,我表示完全晕菜了。。。


GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Thu Nov  3 21:59:02 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".Attaching to process 1967.
2013-05-10 16:22:16.922 HelloWorld[1967:f803] -[ViewController setUserName:]: unrecognized selector sent to instance 0x68419d0
2013-05-10 16:22:16.935 HelloWorld[1967:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController setUserName:]: unrecognized selector sent to instance 0x68419d0'
*** First throw call stack:
(0x13ba052 0x154bd0a 0x13bbced 0x1320f00 0x1320ce2 0x2f1b 0x13bbec9 0x145c2 0x1455a 0xb9b76 0xba03f 0xb92fe 0x39a30 0x39c56 0x20384 0x13aa9 0x12a4fa9 0x138e1c5 0x12f3022 0x12f190a 0x12f0db4 0x12f0ccb 0x12a3879 0x12a393e 0x11a9b 0x2908 0x2865)
terminate called throwing an exceptionsharedlibrary apply-load-rules all
Current language:  auto; currently objective-c
(gdb) 

------解决方案--------------------
意思是说编译器不认识setUserName这个方法
------解决方案--------------------

#import "ViewController.h"
@interface ViewController();
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UITextField *textField;
- (IBAction)changeGreeting:(id)sender;
@end
@implementation ViewController
@synthesize userName;

缺少这句@synthesize userName;
  相关解决方案