In Cocoa/Objective C, are static class methods thread safe ? I am defining a class to make related custom URL requests, that I would like to call from many different threads. Let's say I have a class:
@interface URLConnector : NSObject {
}
+(Response *)getData:(NSString *)category;
+(Response *)put:(NSString *)category content:(NSData *)content;
@end
Each method defines an NSMutableURLRequest, calls it, and uses NSRunLoop:runUntilDate: to wait for the response. They also create instances of another class, URLConnectorDelegate to handle the callbacks from the NSMutableRequests, and release them before returning. (note: this code is based on a popular public library for making URL requests)
What I like about this approach is that it keeps all the threads simple and puts all the custom server-related code in one place. The threads can execute URL requests with a single function call.
Can all of my threads use these static functions at once to make simultaneous calls (i.e. are static objective-c methods inherently thread-safe) ?