Consider the following ObjC code example:
-(void) doStuffWithString: (String *) someParam {
// Do stuff with someParam
}
If this code were being executed in a multi-threaded app, would it be a good idea to retain/release someParam
? Specifically, I'm thinking of scenarios in which the passed-in parameter is a singleton object shared by many threads. Is the following safer, for example?
-(void) doStuffWithString: (String *) someParam {
[stringParam retain];
// Do stuff with someParam
[stringParam release];
}