大佬教程收集整理的这篇文章主要介绍了ios – 展开segue和委托之间的区别,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个由朋友数组填充的FriendsTableViewController和另一个AddFriendTableViewController,其中包含一个将朋友添加到FriendsTableViewController的功能.
这是我通过展开segue从AddFriendViewController发送数据的方式:
#pragma mark - Navigation // In a storyboard-based application,you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // check whether the Done button was tapped. // If it wasn’t,instead of saving the friend,the method returns without doing anything else. if (sender != self.doneButton) return; // See whether there’s text in the text field. if (self.nameTextField.text.length > 0) { // If there’s text,create a new friend and give it's properties the input from the text fields. self.friend = [[Friend alloc] initWithName:self.nameTextField.text dateOfBirth:self.birthdayDatePicker.date numberOfGifts:0]; } }
这是我通过unwind segue操作将AddFriendTableViewController中的数据添加到FriendsTableViewController中的数组的方法:
#pragma mark - Actions - (IBACtion)unwindSegue:(UIStoryboardSegue *)segue { // Retrieve the source view controller,the controller that is unwinding from. AddFriendTableViewController *soruce = [segue sourceViewController]; // Retrieve the soruce view controller’s friend object. Friend *friend = soruce.friend; // See whether the item exists. // If it’s nil,either the Cancel button closed the screen or the text field had no text,so you don’t want to save the item. if (friend != nil) { // If it does exist,add the item to the friends array. [self.friends addObject:friend]; // Reload the data in the table. [self.tableView reloadData]; } }
现在这可以按照我的意愿工作,所以我希望我不会破坏任何stackoverflow规则或冒犯任何人,但我只是想知道我的示例代码的使用方式与是否使用自定义委托制作相同的方案之间的区别AddFriendViewController的方法.如果有人可以解释它会很棒!
以上是大佬教程为你收集整理的ios – 展开segue和委托之间的区别全部内容,希望文章能够帮你解决ios – 展开segue和委托之间的区别所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。