开发者

Accessing class method in iPhone

开发者 https://www.devze.com 2022-12-15 13:27 出处:网络
How can i access NSObject class method? i have one NSobject开发者_JAVA百科 class for AudioStreaming where the audio gets start and stops,

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

精彩评论

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

关注公众号