开发者

Accessing class method in iPhone

How can i access NSObject class method? i have one NSobject开发者_JAVA百科 class for AudioStreaming where the audio gets start and stops, when i changing the tab i want to stop that streamer by method define in AudioStreaming class how can this be done.

Thank you.


A class method is invoked using the class name and the method. Thus if you have:

@interface AudioStreaming
{
    // ...
}
+(void)startAudio;
+(void)stopAudio;
@end

then all you need to do to call these methods is:

[AudioStreaming startAudio];
// ... do other things...
[AudioStreaming stopAudio];

Note that you cannot refer to instance variables within a class method (as there is no current instance!).

If you want to implement a Singleton, this StackOverflow Singleton answer is a good start.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜