title: iPhone - UIToolbar - delegate method / notification / KVC
body: <p>I'm trying to duplicate the design of the mail app on the iPhone. On the toolbar the label updates / changes to show the status of mail being sent. </p>
  
  <p>What is the best way to duplicate this? The following are what I've thought through and maybe someone can suggest why one of them would work or a new idea.</p>
  
  <p>For unity sake, lets say I have the following views: <code>A -&gt; B -&gt; C - D</code>. <code>A</code>, <code>B</code>, and <code>C</code> are pushed on and off the UINavigationController and have the toolbar in question. <code>D</code> is the "compose" window and is a modal window of <code>C</code>. And lets call the object I'm trying to create is <code>obj</code>.</p>
  
  <p><strong>Delegate</strong></p>
  
  <p>This would require me creating one <code>obj</code> in <code>A</code> and pass it to <code>B</code>, and <code>C</code>. <code>C</code> would call a method such as <code>sendMail</code> on <code>obj</code> and it would attempt to send the email. 'obj' would have a delegate method <code>obj:hasUpdateForToolbar:</code> which would send an array to the delegated class (<code>C</code>) in order to update the toolbar. Through the send process it would send multiple messages in order to update a progress bar and at the end to say it was successful sent or a date at which the last email check happened.</p>
  
  <p><em>The problem</em> with this solution is it doesn't update <code>A</code> or <code>B</code>. When <code>C</code> gets popped off, it the delegate would need to be reassigned to <code>B</code> and there would be (I think) a flash of the old value in the toolbar before the next value is pushed by <code>obj</code>.</p>
  
  <p><strong>Notifications</strong></p>
  
  <p>This would be cleaner than the delegate in that you wouldn't have to pass the object to every class which means less dependency between classes). But since you have no connection you would have to have <code>C</code> post a notification that there is a new mail ready to be sent. <code>obj</code> would have to receive that notification and then would have post new notifications instead of the delegate method.</p>
  
  <p><em>The problem</em> with this is that it is common practice to unsubscribe to a notification when the view isn't being shown. So I think there would be the same flash as <code>B</code> subscribes to the notification and waits for it to get pushed the next update for the toolbar.</p>
  
  <p><strong>KVC</strong></p>
  
  <p>I'm really not sure how I could set this up so that Key-Value Coding takes care of it. Am I able to setup a view in <code>obj</code> that gets put into the toolbar of each view and as it gets updated (either with a label or progress bar) it would be reflected in every toolbar?</p>
  
  <p>So which is best / what am I missing on these?</p>