开发者

iphone,where do i declare a global method that can called in all the classes [closed]

开发者_StackOverflow中文版 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜