.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