我从一个班级到另一个班级的NSString
我有一个测验视图控制器,用户在UITextView中输入一个问题然后按下它们去选择朋友视图控制器,他们选择一个用户,然后通过parse.com发送问题
(master) $: phpunit
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/local/opt/php56-imagick/imagick.so' - dlopen(/usr/local/opt/php56- imagick/imagick.so, 9): Symbol not found: _core_globals
Referenced from: /usr/local/opt/php56-imagick/imagick.so
Expected in: flat namespace
in /usr/local/opt/php56-imagick/imagick.so in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php56-imagick/imagick.so' - dlopen(/usr/local/opt/php56-imagick/imagick.so, 9): Symbol not found: _core_globals
Referenced from: /usr/local/opt/php56-imagick/imagick.so
Expected in: flat namespace
in /usr/local/opt/php56-imagick/imagick.so in Unknown on line 0
为什么字符串显示null?在quiz.m中当我按下一个字符串传递为null时,任何关于我如何修复的想法?
答案 0 :(得分:0)
在下一个按钮操作下的quizViewController中
- (IBAction)next:(id)sender {
if ([text length] == 0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error!"
message:@"Enter some text"
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
} else {
selectFriendsViewController *sfvc = [[selectFriendsViewController alloc] init];
sfvc.string = self.textField.text;
}
}
然后在selectFriendsViewController.m
中- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"string %@",self.string);
}
同时检查textView的插座是否已连接到UITextView
。如果没有,那么连接它。并selectFriendsViewController.h,创建属性@property (nonatomic, strong) NSString *string;
希望它可以帮到你。
答案 1 :(得分:0)
selectfriendsviewcontroller.m
如果您使用string
>,您也可以从string
属性访问字符串的值(顺便提一下,请避免使用Xcode
等通用名称) 4.4您可以跳过@synthezise
selectfriendsviewcontroller.m
中的
-(void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"%@",self.string);
}