Using blocks to pass data back to view controller

后端 未结 4 541
没有蜡笔的小新
没有蜡笔的小新 2021-01-06 11:20

I was looking at this question.

One of the answers shows how to use blocks to pass data backwards view the prepareForSegue method. My understanding is t

4条回答
  •  悲&欢浪女
    2021-01-06 11:44

    I know that you asked specifically for a solution that did not involve prepareForSegue but this appears to be based on the assumption that prepareForSegue is for passing data forward only.

    There is something called an unwind segue which might be helpful in your situation. There is a detailed discussion on SO here.

    If you specifically want to use blocks for this, you can simply add a block property to your child controller and have the parent controller set the block. The child controller would have to invoke the block when it is being dismissed. Beware of retain loops if you do this. It doesn't sound to me like blocks are the best solution in this context but it's difficult to say something like that with authority without having a lot more context.

提交回复
热议问题