title: Generalize and optimize speech bubble logic in Objective-C
body: <p>I am working on a children's book app and would like to dynamically populate speech bubble(s) for character dialogues on every scene. I got the animation and dialogue working and below is the code for that. I would have multiple pages in my book, every page would have multiple characters and every character would have multiple dialogues. What is the best way to make this a generic approach so I can use it repeatedly. Can I store the dialogues in TEXT/XML file and read and display them dynamically based on following parameters: Page number, Character number, dialogue number?</p>
  
  <pre><code>UIImage *bubble = [[UIImage imageNamed:@"BubbleLefthand.png"] 
                                 resizableImageWithCapInsets:UIEdgeInsetsMake(15, 21, 15, 21)];
              UIImageView *imgView = [[[UIImageView alloc] initWithImage:bubble] autorelease];
              imgView.frame = CGRectMake(250, 350, 0, 0);
              UILabel  *xlabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
              xlabel.text = @"This is a dialogue text!!!";
  
              [imgView addSubview:xlabel];
              [self.view addSubview:imgView];
              [UIView animateWithDuration:0.5
                               animations:^(void) {
                                   imgView.frame = CGRectMake(250, 350, 300, -40);
                                   xlabel.frame = CGRectMake(30, 10, 200, 20);
                               } completion:^(BOOL finished) {
                                   STLog(@"ChildrenBookViewController ==&gt; SPPECH BUBBLE ANIMATION COMPLETE. Switch Case: %d", pageNum);
                               }];
  </code></pre>
  
  <p>Currently my dialogue shows like attach screenshot.
  <img src="https://i.stack.imgur.com/w7KOU.png" alt="enter image description here"></p>