.H的iOS,NSString的属性困惑为的UITextField
@interface HuntProfileView : UIViewController
@property (strong, nonatomic) NSString *huntgroupTitle;
@property (strong, nonatomic) NSString *huntgroupId;
@property (strong, nonatomic) NSArray *lines;
@end
的.m
@interface HuntProfileView()
@property (weak, nonatomic) IBOutlet UITextField *huntgrouptitleText;
@property HuntLineTable *childView;
@end
@implementation HuntProfileView
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"huntgroupTitle %@", self.huntgroupTitle);
self.huntgrouptitleText.text = self.huntgroupTitle;
}
实例,分配&执行
viewController.huntgroupTitle = title;
是正确的,或者至少title是预期的字符串。
的的NSLog在.m
输出为:
2015-01-21 09:47:42.267 changeView[1108:16196] huntgroupTitle <UITextField: 0x7fa9a8fc8480; frame = (16 63; 568 30); text = ''; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x7fa9a8fc9c70>>
2015-01-21 09:47:42.267 changeView[1108:16196] -[UITextField rangeOfCharacterFromSet:]: unrecognized selector sent to instance 0x7fa9a8fc8480
2015-01-21 09:47:42.270 changeView[1108:16196] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextField rangeOfCharacterFromSet:]: unrecognized selector sent to instance 0x7fa9a8fc8480'
更新:
分配self.huntgroupTitle
一个字符串( “你好,世界”)时,我能够得到成功执行。调试表明,在实例化时,输入字符串title
以及viewController.huntgroupTitle
被确认为正确的类型。
你应该把在断点处“viewController.huntgroupTitle =称号;”并检查标题。如果这不起作用,则覆盖“huntgroupTitle”的设置程序,并在其中放置一个断点以检查它的分配时间。 – Aris 2015-01-21 10:05:05
问题不在你的'ViewDidLoad'中,请检查在**中添加'rangeOfCharacterFromSet'的位置。m ** – 2015-01-21 10:05:51
需要更多代码。这通常发生在您意外地将“NSString”类型的变量赋值给“UITextField”类型的变量时。 – avismara 2015-01-21 10:10:29