title: How to call a function from another class file
body: <p>I am very familiar with writing VB based applications but am new to Xcode (and Objective C). I have gone through numerous tutorials on the web and understand the basics and how to interact with Interface Builder etc. However, I am really struggling with some basic concepts of the C language and would be grateful for any help you can offer. Heres my problem…</p>
  
  <p>I have a simple iphone app which has a view controller (FirstViewController) and a subview (SecondViewController) with associated header and class files.</p>
  
  <p>In the FirstViewController.m have a function defined</p>
  
  <pre><code>@implementation FirstViewController
  
  - (void) writeToServer:(const uint8_t *) buf {
      [oStream write:buf maxLength:strlen((char*)buf)];   
  }
  </code></pre>
  
  <p>It doesn't really matter what the function is.</p>
  
  <p>I want to use this function in my SecondViewController, so in SecondViewController.m I import FirstViewController.h</p>
  
  <pre><code>#import "SecondViewController.h"
  #import "FirstViewController.h"
  
  @implementation SecondViewController
  
  -(IBAction) SetButton: (id) sender {
      NSString *s = [@"Fill:" stringByAppendingString: FillLevelValue.text];
      NSString *strToSend = [s stringByAppendingString: @":"];
      const uint8_t *str = (uint8_t *) [strToSend cStringUsingEncoding:NSASCIIStringEncoding];
      FillLevelValue.text = strToSend;
  
      [FirstViewController writeToServer:str];
  }
  </code></pre>
  
  <p>This last line is where my problem is.
  XCode tells me that FirstViewController may not respond to writeToServer.
  And when I try to run the application it crashes when this function is called.</p>
  
  <p>I guess I don't fully understand how to share functions and more importantly, the relationship between classes.</p>
  
  <p>In an ideal world I would create a global class to place my functions in and call them as required.</p>
  
  <p>Any advice gratefully received.</p>