Is it possible to use the return value of a开发者_StackOverflow中文版 method as the argument for a different method invocation? I'm using Objective-C.
What I'm going for is something like this:
stringOutput = [object1 method1:[object2 method2:[object3 method3]]];
where method 3 returns a string that goes into method 2, which returns a string that goes into method 1, which returns a string that goes into stringOutput.
Do you mean sending the result from one method as the parameter for another?
NSString *string = [self myMethod:[self myMethod2]];
Where the methods are
- (NSString *)myMethod2 {
return @"A String";
}
- (NSString *)myMethod:(NSString *)string {
// Do something with string
// Return another string
return @"Something else";
}
精彩评论