Reputation: 64834
I dont undesratand in which situations is more convenient to pass references as functions parameters:
- (void)exportXMLToString:(NSMutableString **)aString
Can I just pass the string by value and have it back when the method finishes to execute ?
Thanks
Upvotes: 2
Views: 121
Reputation: 1289
As I understand what you are trying to achieve, you could just name your method - (NSString *)xmlStringValue
.
It is a matter of style, I personally only use references in ObjC when I have to (it is not really in the spirit of the language imho), and almost exclusively for (NSError **)
.
Upvotes: 0
Reputation: 2470
You may find the following thread useful. I think your issue is vastly discussed here: Use of pass by reference in Objective-C
Upvotes: 1
Reputation: 4493
It more convenient to pass references when you do not want an extra copy of String, Extra copy means more space, If you want to read/append the String< It is better if you do not create a new new one. You easily do this by passing String value (create a new one) but that's not very efficient. (you want two glasses space to store 1/2 glass of water :) )
Upvotes: 0