How can i write a global method that can be called anywhere in my iPhone App Can any one Help Please....
You can write global functions (not part of a class) wherever you like. Just add the declaration where you use it (i.e. include a header file).
For example:
File globalfunctions.h
void doCoolStuff();
File globalfunctions.c
#include "globalfunctions.h"
void doCoolStuff()
{
}
and where you use it use
#include "globalfunctions.h" // or
#import "globalfunctions.h"
You would normally use the Singleton Class to contain global data and methods for your iphone application. Here are 2 good references: Singleton Tutorial, Singleton Pattern
精彩评论