Re: returning value in a function argument
Re: returning value in a function argument
- Subject: Re: returning value in a function argument
- From: Scott Ellsworth <email@hidden>
- Date: Wed, 17 May 2006 17:47:30 -0700
On May 17, 2006, at 5:38 PM, Angelo Chen wrote:
Hi Scott,
setString works, thanks. any sample code for NSArray
method?
I am not sure which strings you want in the array. Assuming that you
want the passed in string first, and the 'info string' second, it
would look something like:
NSArray * getInfo(NSString * firstString){
return [NSArray arrayWithObjects:firstString, @"my info", nil];
}
Note: this is an autoreleased array, so retain if you want to keep it
around. You would then get the first one out via
NSArray * myInfoResults = getInfo(@"first string");
NSString * firstString = [myInfoResults objectAtIndex:0];
NSString * secondString = [myInfoResults objectAtIndex:1];
This is documented at: <http://devworld.apple.com/documentation/Cocoa/
Reference/Foundation/ObjC_classic/Classes/NSArray.html>
Scott
--- Scott Ellsworth <email@hidden> wrote:
What about returning either an object made up of the
two strings, or
an NSArray or NSDictionary with the two strings in
it?
(BTW, did your mutable string code look something
like:
void getInfo(NSMutableString * info){
[info setString:@"my info"];
}
I would have thought that would work if you wanted
info to change.
Scott
_______________________________________________
Do not post admin requests to the list. They will be
ignored.
Cocoa-dev mailing list
(email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden