更好的方法是NSString*
在AddTaskViewController
. 你可以这样做:
添加AddTaskViewController.h
以下内容:
@property (nonatomic, strong) NSString* myLabelsText;
然后AddTaskViewController.m
确保将其添加到viewWillAppear
:
self.testlabel.text = self.myLabelsText;
现在假设您已经适当地声明了您的testLabel
和myLabelsText
它们被合成,您的视图控制器将在适当的时间正确应用字符串,然后您的函数应该更改为:
- (IBAction)donebutton:(id)sender {
AddTaskViewController *addtask = [[AddTaskViewController alloc]initWithNibName:@"AddTask" bundle:nil];
// Set the value on your new NSString* property and let the view controller handle the rest
addTask.myLabelsText = self.zaman1.text;
// Don't you want to 'present' the view controller rather than 'dismiss' after having provided it with data?
[self dismissViewControllerAnimated:YES completion:nil];
}